Skip to content

Commit

Permalink
refactor: remove needless set_init (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethe authored Oct 18, 2024
1 parent d0f4b06 commit 8249fa4
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 23 deletions.
2 changes: 0 additions & 2 deletions fusio-object-store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ impl<O: ObjectStore> S3File<O> {
Err(e) => return (Err(e.into()), buf),
};

buf.set_init(bytes.len());

buf.as_slice_mut().copy_from_slice(&bytes);
(Ok(bytes.len() as u64), buf)
}
Expand Down
12 changes: 0 additions & 12 deletions fusio/src/buf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ pub trait IoBuf: Unpin + Sized + MaybeOwned + MaybeSend {
}

pub trait IoBufMut: IoBuf {
fn set_init(&mut self, init: usize);

fn as_mut_ptr(&mut self) -> *mut u8;

fn as_slice_mut(&mut self) -> &mut [u8] {
Expand Down Expand Up @@ -105,10 +103,6 @@ impl IoBuf for Vec<u8> {
}

impl IoBufMut for Vec<u8> {
fn set_init(&mut self, init: usize) {
self.resize(init, 0);
}

fn as_mut_ptr(&mut self) -> *mut u8 {
Vec::as_mut_ptr(self)
}
Expand Down Expand Up @@ -192,8 +186,6 @@ impl IoBuf for &mut [u8] {

#[cfg(not(feature = "completion-based"))]
impl IoBufMut for &mut [u8] {
fn set_init(&mut self, _init: usize) {}

fn as_mut_ptr(&mut self) -> *mut u8 {
<[u8]>::as_mut_ptr(self)
}
Expand Down Expand Up @@ -334,10 +326,6 @@ impl IoBuf for bytes::BytesMut {

#[cfg(feature = "bytes")]
impl IoBufMut for bytes::BytesMut {
fn set_init(&mut self, init: usize) {
self.resize(init, 0)
}

fn as_mut_ptr(&mut self) -> *mut u8 {
<[u8]>::as_mut_ptr(self)
}
Expand Down
9 changes: 0 additions & 9 deletions fusio/src/buf/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,6 @@ impl IoBuf for SliceMut {
}

impl IoBufMut for SliceMut {
fn set_init(&mut self, init: usize) {
match &mut self.layout {
SliceMutLayout::Slice { .. } => {}
SliceMutLayout::Vec(vec) => vec.set_init(init),
#[cfg(feature = "bytes")]
SliceMutLayout::BytesMut(bytes) => bytes.set_init(init),
}
}

fn as_mut_ptr(&mut self) -> *mut u8 {
match &mut self.layout {
SliceMutLayout::Slice { ptr, .. } => unsafe { (*ptr).add(self.start) },
Expand Down

0 comments on commit 8249fa4

Please sign in to comment.