зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #10983 - Minor reduction in the amount of allocation display list building does (from notriddle:no_alloc_sort_display); r=mbrubeck
Use `mem::replace` to perform the lifetime-trick without allocating a whole new buffer. (An older of this switched from the built-in heapsort to a non-allocating introsort. Unfortunately, introsort is not a stable sorting algorithm, and the display list system relies on it being stable.) Source-Repo: https://github.com/servo/servo Source-Revision: 2e849b7064bdb30beedc4af13033b3f6a407f4b1
This commit is contained in:
Родитель
1379121bd9
Коммит
ecd9f482b8
|
@ -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) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче