From e1683f41c6e6f5a4b80372abaaba0d5bf0bd1ad0 Mon Sep 17 00:00:00 2001 From: ErrorNoInternet Date: Thu, 13 Mar 2025 18:00:14 -0400 Subject: [PATCH] refactor: get rid of smallvec Doesn't seem to be doing much. --- Cargo.lock | 1 - Cargo.toml | 1 - src/replay/recorder.rs | 11 +++++------ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f70b781..544510c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1417,7 +1417,6 @@ dependencies = [ "ncr", "parking_lot", "serde_json", - "smallvec", "tokio", "zip", ] diff --git a/Cargo.toml b/Cargo.toml index 0a60a87..7e8cfed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,6 @@ mlua = { version = "0", features = ["async", "luajit", "send"] } ncr = { version = "0", features = ["cfb8", "ecb", "gcm"] } parking_lot = "0" serde_json = "1" -smallvec = { version = "1", features = ["write"] } tokio = { version = "1", features = ["macros"] } zip = { version = "2", default-features = false, features = ["flate2"] } diff --git a/src/replay/recorder.rs b/src/replay/recorder.rs index 31b5ee3..7e2ae2f 100644 --- a/src/replay/recorder.rs +++ b/src/replay/recorder.rs @@ -7,7 +7,6 @@ use azalea::{ }; use log::debug; use serde_json::json; -use smallvec::SmallVec; use std::{ fs::File, io::Write, @@ -69,16 +68,16 @@ impl Recorder { } pub fn save_raw_packet(&mut self, raw_packet: &[u8]) -> Result<()> { - let mut data = SmallVec::<[u8; 128]>::with_capacity(raw_packet.len() + 8); - data.write_all(&TryInto::::try_into(self.start.elapsed().as_millis())?.to_be_bytes())?; - data.write_all(&TryInto::::try_into(raw_packet.len())?.to_be_bytes())?; - data.write_all(raw_packet)?; + let mut data = Vec::with_capacity(raw_packet.len() + 8); + data.extend(TryInto::::try_into(self.start.elapsed().as_millis())?.to_be_bytes()); + data.extend(TryInto::::try_into(raw_packet.len())?.to_be_bytes()); + data.extend(raw_packet); self.zip_writer.write_all(&data)?; Ok(()) } pub fn save_packet(&mut self, packet: &T) -> Result<()> { - let mut raw_packet = SmallVec::<[u8; 128]>::new(); + let mut raw_packet = Vec::with_capacity(64); packet.id().azalea_write_var(&mut raw_packet)?; packet.write(&mut raw_packet)?; self.save_raw_packet(&raw_packet)