refine BinRead Args tech
This commit is contained in:
parent
85537484d1
commit
77af5e386a
14
src/v0.rs
14
src/v0.rs
@ -390,12 +390,8 @@ struct EventChunkHeader{
|
||||
num_events:u32,
|
||||
}
|
||||
|
||||
// first time I've managed to write BinRead generics without this stupid T::Args<'a>:Required thing blocking me
|
||||
fn read_data_into_events<'a,R:BinReaderExt,T>(data:&mut R,events:&mut Vec<T>,num_events:usize)->binrw::BinResult<()>
|
||||
where
|
||||
T:binrw::BinRead,
|
||||
T::Args<'a>:binrw::__private::Required,
|
||||
{
|
||||
// binread args tech has been further refined
|
||||
fn read_data_into_events<'a,R:BinReaderExt,T:binrw::BinRead<Args<'a>=()>>(data:&mut R,events:&mut Vec<T>,num_events:usize)->binrw::BinResult<()>{
|
||||
// there is only supposed to be at most one of each type of event chunk per block, so no need to amortize.
|
||||
events.reserve_exact(num_events);
|
||||
for _ in 0..num_events{
|
||||
@ -403,11 +399,7 @@ where
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
fn read_data_into_events_amortized<'a,R:BinReaderExt,T>(data:&mut R,events:&mut Vec<T>,num_events:usize)->binrw::BinResult<()>
|
||||
where
|
||||
T:binrw::BinRead,
|
||||
T::Args<'a>:binrw::__private::Required,
|
||||
{
|
||||
fn read_data_into_events_amortized<'a,R:BinReaderExt,T:binrw::BinRead<Args<'a>=()>>(data:&mut R,events:&mut Vec<T>,num_events:usize)->binrw::BinResult<()>{
|
||||
// this is used when reading multiple blocks into a single object, so amortize the allocation cost.
|
||||
events.reserve(num_events);
|
||||
for _ in 0..num_events{
|
||||
|
Loading…
x
Reference in New Issue
Block a user