Use bytes crate for zerocopy and memory re-use (#182)
* Use bytes. Not yet zerocopy everywhere but compiles * Actually zerocopy * Actually zerocopy * Not actually storing the torrent on disk now
This commit is contained in:
parent
3cc9e444b1
commit
c7ed475f54
20 changed files with 182 additions and 95 deletions
|
|
@ -1,6 +1,7 @@
|
|||
use std::{collections::HashMap, marker::PhantomData};
|
||||
|
||||
use buffers::{ByteBuf, ByteBufOwned};
|
||||
use bytes::Bytes;
|
||||
use clone_to_owned::CloneToOwned;
|
||||
use serde::Deserializer;
|
||||
|
||||
|
|
@ -122,12 +123,12 @@ where
|
|||
{
|
||||
type Target = BencodeValue<<BufT as CloneToOwned>::Target>;
|
||||
|
||||
fn clone_to_owned(&self) -> Self::Target {
|
||||
fn clone_to_owned(&self, within_buffer: Option<&Bytes>) -> Self::Target {
|
||||
match self {
|
||||
BencodeValue::Bytes(b) => BencodeValue::Bytes(b.clone_to_owned()),
|
||||
BencodeValue::Bytes(b) => BencodeValue::Bytes(b.clone_to_owned(within_buffer)),
|
||||
BencodeValue::Integer(i) => BencodeValue::Integer(*i),
|
||||
BencodeValue::List(l) => BencodeValue::List(l.clone_to_owned()),
|
||||
BencodeValue::Dict(d) => BencodeValue::Dict(d.clone_to_owned()),
|
||||
BencodeValue::List(l) => BencodeValue::List(l.clone_to_owned(within_buffer)),
|
||||
BencodeValue::Dict(d) => BencodeValue::Dict(d.clone_to_owned(within_buffer)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue