Skip to content

Commit

Permalink
refactor(data_structures): CodeBuffer::print_bytes_unchecked take a…
Browse files Browse the repository at this point in the history
… byte slice (#9327)

Alter signature of `CodeBuffer::print_bytes_unchecked`, to take a byte slice instead of an iterator.

This would be a breaking change, but `CodeBuffer` was only made public in last PR (#9326), so no-one will have had a chance to depend on it yet!
  • Loading branch information
overlookmotel committed Feb 24, 2025
1 parent 9d98444 commit beb8382
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions crates/oxc_data_structures/src/code_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,20 +358,16 @@ impl CodeBuffer {
/// # use oxc_data_structures::CodeBuffer;
/// let mut code = CodeBuffer::new();
///
/// // Indent to a dynamic level.
/// // Sound because all elements in this iterator are ASCII characters.
/// // Sound because all bytes in this byte slice are ASCII characters
/// unsafe {
/// code.print_bytes_unchecked(std::iter::repeat(b' ').take(4));
/// code.print_bytes_unchecked("abcd".as_bytes());
/// }
/// ```
///
/// [`print_byte_unchecked`]: CodeBuffer::print_byte_unchecked
#[inline]
pub unsafe fn print_bytes_unchecked<I>(&mut self, bytes: I)
where
I: IntoIterator<Item = u8>,
{
self.buf.extend(bytes);
pub unsafe fn print_bytes_unchecked(&mut self, bytes: &[u8]) {
self.buf.extend_from_slice(bytes);
}

/// Print `n` tab characters into the buffer (indentation).
Expand Down

0 comments on commit beb8382

Please sign in to comment.