perf(replay/recorder): reduce SmallVec size to 64

This commit is contained in:
Ryan 2025-03-11 20:01:45 -04:00
parent 15cd2e673e
commit d8ac556884
Signed by: ErrorNoInternet
GPG Key ID: 2486BFB7B1E6A4A3

View File

@ -66,7 +66,6 @@ impl Recorder {
} }
pub fn save_raw_packet(&mut self, raw_packet: &[u8]) -> Result<()> { pub fn save_raw_packet(&mut self, raw_packet: &[u8]) -> Result<()> {
println!("{}", raw_packet.len());
let mut data = Vec::with_capacity(raw_packet.len() + 8); let mut data = Vec::with_capacity(raw_packet.len() + 8);
data.extend(&TryInto::<u32>::try_into(self.start.elapsed().as_millis())?.to_be_bytes()); data.extend(&TryInto::<u32>::try_into(self.start.elapsed().as_millis())?.to_be_bytes());
data.extend(&TryInto::<u32>::try_into(raw_packet.len())?.to_be_bytes()); data.extend(&TryInto::<u32>::try_into(raw_packet.len())?.to_be_bytes());
@ -76,7 +75,7 @@ impl Recorder {
} }
pub fn save_packet<T: ProtocolPacket>(&mut self, packet: &T) -> Result<()> { pub fn save_packet<T: ProtocolPacket>(&mut self, packet: &T) -> Result<()> {
let mut raw_packet = SmallVec::<[u8; 256]>::new(); let mut raw_packet = SmallVec::<[u8; 64]>::new();
packet.id().azalea_write_var(&mut raw_packet)?; packet.id().azalea_write_var(&mut raw_packet)?;
packet.write(&mut raw_packet)?; packet.write(&mut raw_packet)?;
self.save_raw_packet(&raw_packet) self.save_raw_packet(&raw_packet)