Skip to content
Permalink
Browse files

shift should return slice not Box

  • Loading branch information...
ry committed Mar 15, 2019
1 parent 4b899fa commit c36b72c2f7f463b2a399cd222f51b60e9aa4c482
Showing with 2 additions and 6 deletions.
  1. +2 −6 core/shared_queue.rs
@@ -98,7 +98,7 @@ impl SharedQueue {
}

/// Returns none if empty.
pub fn shift<'a>(&'a mut self) -> Option<Buf> {
pub fn shift<'a>(&'a mut self) -> Option<&'a [u8]> {
let u32_slice = self.as_u32_slice();
let i = u32_slice[INDEX_NUM_SHIFTED_OFF] as usize;
if i >= self.num_records() {
@@ -107,15 +107,11 @@ impl SharedQueue {
}
let off = self.get_offset(i).unwrap();
let end = self.get_end(i).unwrap();
// println!("shift {} {}", off, end);
let mut v = Vec::<u8>::new();
v.resize(end - off, 0);
v.copy_from_slice(&self.bytes[off..end]);

let u32_slice = self.as_u32_slice_mut();
u32_slice[INDEX_NUM_SHIFTED_OFF] += 1;

Some(v.into_boxed_slice())
Some(&self.bytes[off..end])
}

pub fn push(&mut self, record: Buf) -> bool {

0 comments on commit c36b72c

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.