refactor: get rid of smallvec
Doesn't seem to be doing much.
This commit is contained in:
parent
477790db0e
commit
e1683f41c6
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -1417,7 +1417,6 @@ dependencies = [
|
|||||||
"ncr",
|
"ncr",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"smallvec",
|
|
||||||
"tokio",
|
"tokio",
|
||||||
"zip",
|
"zip",
|
||||||
]
|
]
|
||||||
|
@ -38,7 +38,6 @@ mlua = { version = "0", features = ["async", "luajit", "send"] }
|
|||||||
ncr = { version = "0", features = ["cfb8", "ecb", "gcm"] }
|
ncr = { version = "0", features = ["cfb8", "ecb", "gcm"] }
|
||||||
parking_lot = "0"
|
parking_lot = "0"
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
smallvec = { version = "1", features = ["write"] }
|
|
||||||
tokio = { version = "1", features = ["macros"] }
|
tokio = { version = "1", features = ["macros"] }
|
||||||
zip = { version = "2", default-features = false, features = ["flate2"] }
|
zip = { version = "2", default-features = false, features = ["flate2"] }
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ use azalea::{
|
|||||||
};
|
};
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use smallvec::SmallVec;
|
|
||||||
use std::{
|
use std::{
|
||||||
fs::File,
|
fs::File,
|
||||||
io::Write,
|
io::Write,
|
||||||
@ -69,16 +68,16 @@ impl Recorder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn save_raw_packet(&mut self, raw_packet: &[u8]) -> Result<()> {
|
pub fn save_raw_packet(&mut self, raw_packet: &[u8]) -> Result<()> {
|
||||||
let mut data = SmallVec::<[u8; 128]>::with_capacity(raw_packet.len() + 8);
|
let mut data = Vec::with_capacity(raw_packet.len() + 8);
|
||||||
data.write_all(&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.write_all(&TryInto::<u32>::try_into(raw_packet.len())?.to_be_bytes())?;
|
data.extend(TryInto::<u32>::try_into(raw_packet.len())?.to_be_bytes());
|
||||||
data.write_all(raw_packet)?;
|
data.extend(raw_packet);
|
||||||
self.zip_writer.write_all(&data)?;
|
self.zip_writer.write_all(&data)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
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; 128]>::new();
|
let mut raw_packet = Vec::with_capacity(64);
|
||||||
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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user