aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2016-05-02 17:28:14 -0700
committerMichael Howell <michael@notriddle.com>2016-05-03 12:57:46 -0700
commit93c9dda7935a73891aa93cda15a9f37216b84d38 (patch)
tree976eaa4a817ba4f9f6acb825cd73d4dae53ced22
parent361b2b900eeea821a9a79d8566f8cd31dfb1b1ea (diff)
downloadservo-93c9dda7935a73891aa93cda15a9f37216b84d38.tar.gz
servo-93c9dda7935a73891aa93cda15a9f37216b84d38.zip
Do not allocate when sorting the display list.
-rw-r--r--components/gfx/display_list/mod.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs
index d0f117b439e..62bb324d873 100644
--- a/components/gfx/display_list/mod.rs
+++ b/components/gfx/display_list/mod.rs
@@ -37,6 +37,7 @@ use std::collections::HashMap;
use std::fmt;
use std::hash::{BuildHasherDefault, Hash};
use std::marker::PhantomData;
+use std::mem;
use std::ops::{Deref, DerefMut};
use std::sync::Arc;
use style::computed_values::{border_style, filter, image_rendering, mix_blend_mode};
@@ -246,8 +247,7 @@ impl DisplayList {
}
fn sort(&mut self) {
- let mut list = Vec::new();
- list.append(&mut self.list);
+ let mut list = mem::replace(&mut self.list, Vec::new());
list.sort_by(|a, b| {
if a.base().stacking_context_id == b.base().stacking_context_id {
@@ -256,7 +256,7 @@ impl DisplayList {
self.get_offset_for_item(a).cmp(&self.get_offset_for_item(b))
});
- self.list.append(&mut list);
+ mem::replace(&mut self.list, list);
}
pub fn print(&self) {