Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use deserialize_from for faster deserialization #2128

Merged
merged 2 commits into from Dec 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
61 changes: 38 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Expand Up @@ -8,3 +8,7 @@ members = [
[profile.release]
debug = true
panic = "abort"

[replace]
"serde:1.0.23" = { git = "https://github.com/gankro/serde", branch = "deserialize_from_enums3" }
"serde_derive:1.0.23" = { git = "https://github.com/gankro/serde", branch = "deserialize_from_enums3", feature="deserialize_from" }
3 changes: 2 additions & 1 deletion webrender_api/Cargo.toml
Expand Up @@ -16,7 +16,8 @@ bincode = "0.9"
byteorder = "1.2.1"
euclid = "0.16"
ipc-channel = {version = "0.9", optional = true}
serde = { version = "1.0", features = ["rc", "derive"] }
serde = { version = "1.0.23", features = ["rc", "derive"] }
serde_derive = { version = "1.0.23", features = ["deserialize_from"] }
time = "0.1"

[target.'cfg(target_os = "macos")'.dependencies]
Expand Down
1 change: 1 addition & 0 deletions webrender_api/src/display_item.rs
Expand Up @@ -88,6 +88,7 @@ impl LayerPrimitiveInfo {
pub type LayoutPrimitiveInfo = PrimitiveInfo<LayoutPixel>;
pub type LayerPrimitiveInfo = PrimitiveInfo<LayerPixel>;

#[repr(u8)]
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub enum SpecificDisplayItem {
Clip(ClipDisplayItem),
Expand Down
8 changes: 6 additions & 2 deletions webrender_api/src/display_list.rs
Expand Up @@ -225,8 +225,12 @@ impl<'a> BuiltDisplayListIter<'a> {
return None;
}

self.cur_item = bincode::deserialize_from(&mut UnsafeReader::new(&mut self.data), bincode::Infinite)
.expect("MEH: malicious process?");
{
let reader = bincode::read_types::IoReader::new(UnsafeReader::new(&mut self.data));
let mut deserializer = bincode::Deserializer::new(reader, bincode::Infinite);
self.cur_item.deserialize_from(&mut deserializer)
.expect("MEH: malicious process?");
}

match self.cur_item.item {
SetGradientStops => {
Expand Down