mirror of
https://github.com/loro-dev/loro.git
synced 2024-10-23 13:09:47 +00:00
refactor: refine compact bytes interface
This commit is contained in:
parent
3771566b9f
commit
d26bb4e5c9
2 changed files with 5 additions and 1 deletions
|
@ -6,6 +6,6 @@ pub fn main() {
|
|||
for _ in 0..1000 {
|
||||
let mut bytes = CompactBytes::new();
|
||||
bytes.append(&black_box(data).as_bytes()[..data.len() / 2]);
|
||||
bytes.alloc_advance(&black_box(&data.as_bytes()[data.len() / 2..]));
|
||||
bytes.alloc_advance(black_box(&data.as_bytes()[data.len() / 2..]));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,6 +62,10 @@ impl CompactBytes {
|
|||
self.capacity
|
||||
}
|
||||
|
||||
pub fn take(self) -> AppendOnlyBytes {
|
||||
self.bytes
|
||||
}
|
||||
|
||||
pub fn from_bytes(bytes: &[u8]) -> Self {
|
||||
let mut compact_bytes = CompactBytes::new();
|
||||
compact_bytes.append(bytes);
|
||||
|
|
Loading…
Reference in a new issue