From e7f7cd4122e7227244c63ac845afc4f340b7fd75 Mon Sep 17 00:00:00 2001 From: Cai Bear Date: Sat, 23 Mar 2024 23:58:18 -0700 Subject: [PATCH] Update bitcode. --- Cargo.toml | 2 +- src/bench_bitcode.rs | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 95c71d9..4631011 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,7 +53,7 @@ bebop = { version = "2.4.9", optional = true } bincode1 = { package = "bincode", version = "1.3.3", optional = true } # Can't call it bincode2 because of a current issue of bincode2 bincode = { package = "bincode", version = "2.0.0-rc", optional = true } -bitcode = { version = "=0.6.0-alpha.2", optional = true } +bitcode = { version = "0.6.0", optional = true } borsh = { version = "1.1.1", features = ["derive"], optional = true } # TODO: Unfork after bson adds support for pre-warmed serialization buffers # https://github.com/mongodb/bson-rust/pull/328 diff --git a/src/bench_bitcode.rs b/src/bench_bitcode.rs index 65659fc..96196b4 100644 --- a/src/bench_bitcode.rs +++ b/src/bench_bitcode.rs @@ -6,7 +6,7 @@ where T: Encode + DecodeOwned + PartialEq, { let mut group = c.benchmark_group(format!("{}/bitcode", name)); - let mut buffer = bitcode::EncodeBuffer::::default(); + let mut buffer = bitcode::Buffer::new(); group.bench_function("serialize", |b| { b.iter(|| { @@ -14,18 +14,17 @@ where }) }); - let encoded = buffer.encode(data); - let mut buffer = bitcode::DecodeBuffer::::default(); + let encoded = buffer.encode(data).to_vec(); group.bench_function("deserialize", |b| { b.iter(|| { - black_box(buffer.decode(black_box(&encoded)).unwrap()); + black_box(buffer.decode::(black_box(&encoded)).unwrap()); }) }); - crate::bench_size(name, "bitcode", encoded); + crate::bench_size(name, "bitcode", &encoded); - assert!(buffer.decode(&encoded).unwrap() == *data); + assert!(buffer.decode::(&encoded).unwrap() == *data); group.finish(); }