Skip to content

Commit

Permalink
owning_iovec: rename advance_by_bytes -> advance_slices
Browse files Browse the repository at this point in the history
  • Loading branch information
pkhuong committed May 25, 2024
1 parent 5b906fb commit 9f241d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/owning_iovec/implementation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ impl<'a> ConsumingIovec<'a> {
/// Pops up to the next `count` bytes in the slices returned by [`OwningIovec::stable_prefix`].
///
/// Returns the number of bytes consumed.
pub fn advance_by_bytes(&'a mut self, count: usize) -> usize {
pub fn advance_slices(&'a mut self, count: usize) -> usize {
let mut stable_count = 0;
for slice in self.stable_prefix() {
let size = slice.len();
Expand Down Expand Up @@ -521,19 +521,19 @@ fn test_happy_optimize_miri() {
assert_eq!(dst, b"0001234567aaa");

// now consume 4 bytes.
assert_eq!(iovs.consumer().advance_by_bytes(4), 4);
assert_eq!(iovs.consumer().advance_slices(4), 4);
assert_eq!(iovs.len(), 2);
assert_eq!(iovs.total_size(), 9);

assert_eq!(iovs.flatten().unwrap(), b"234567aaa");

assert_eq!(iovs.consumer().advance_by_bytes(100), 9);
assert_eq!(iovs.consumer().advance_slices(100), 9);
assert!(iovs.is_empty());
assert_eq!(iovs.len(), 0);
assert_eq!(iovs.total_size(), 0);
assert_eq!(iovs.flatten().unwrap(), b"");

assert_eq!(iovs.consumer().advance_by_bytes(100), 0);
assert_eq!(iovs.consumer().advance_slices(100), 0);
assert_eq!(iovs.flatten().unwrap(), b"");
}

Expand Down
4 changes: 2 additions & 2 deletions src/shard_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl ShardWriter {
Err(e) => return Err(e),
}
};
self.encoder.consumer().advance_by_bytes(written);
self.encoder.consumer().advance_slices(written);
if written == 0 && byte_count > 0 {
Err(std::io::Error::new(
std::io::ErrorKind::WriteZero,
Expand Down Expand Up @@ -224,7 +224,7 @@ impl ShardWriter {
));
}

iovec.consumer().advance_by_bytes(written);
iovec.consumer().advance_slices(written);
}

Ok(())
Expand Down

0 comments on commit 9f241d8

Please sign in to comment.