Skip to content

Commit 457ebf5

Browse files
committed
Switch to bitcode.
Bitcode has a better performance characteristics at the moment. Signed-off-by: Narfinger <[email protected]>
1 parent ba821ce commit 457ebf5

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ipc-channel"
3-
version = "0.20.1"
3+
version = "0.21.0"
44
description = "A multiprocess drop-in replacement for Rust channels"
55
authors = ["The Servo Project Developers"]
66
license = "MIT OR Apache-2.0"
@@ -31,7 +31,7 @@ win32-trace = []
3131
enable-slow-tests = []
3232

3333
[dependencies]
34-
bincode = "1"
34+
bitcode = { version = "0.6.6", features = ["serde"] }
3535
crossbeam-channel = "0.5"
3636
fnv = "1.0.3"
3737
futures-channel = { version = "0.3.31", optional = true }

src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use thiserror::Error;
55

66
#[derive(Debug, Error)]
77
/// An error that occurs for serialization or deserialization
8-
pub struct SerializationError(#[from] pub(crate) bincode::Error);
8+
pub struct SerializationError(#[from] pub(crate) bitcode::Error);
99

1010
impl Display for SerializationError {
1111
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {

src/ipc.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::platform::{
1414
};
1515
use crate::{IpcError, TryRecvError};
1616

17-
use bincode;
17+
use bitcode;
1818
use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer};
1919
use std::cell::RefCell;
2020
use std::cmp::min;
@@ -330,7 +330,8 @@ where
330330
let os_ipc_shared_memory_regions;
331331
let os_ipc_channels;
332332
{
333-
bincode::serialize_into(&mut bytes, &data).map_err(SerializationError)?;
333+
bytes = bitcode::serialize(&data).map_err(SerializationError)?;
334+
334335
os_ipc_channels = mem::replace(
335336
&mut *os_ipc_channels_for_serialization.borrow_mut(),
336337
old_os_ipc_channels,
@@ -697,7 +698,7 @@ impl IpcMessage {
697698
.map(Some)
698699
.collect(),
699700
);
700-
let result = bincode::deserialize(&self.data[..]).map_err(|e| e.into());
701+
let result = bitcode::deserialize(&self.data[..]).map_err(|e| e.into());
701702
*os_ipc_shared_memory_regions_for_deserialization.borrow_mut() =
702703
old_ipc_shared_memory_regions_for_deserialization;
703704
mem::swap(

0 commit comments

Comments
 (0)