Use a BTreeMap for Document::animation_frame_list (fixes #9834)

The callbacks must stay ordered.
This commit is contained in:
Anthony Ramine 2016-03-02 14:23:47 +01:00
parent f7db68eff7
commit 1d87f61350
4 changed files with 66 additions and 10 deletions

View file

@ -70,7 +70,7 @@ use serde::{Deserialize, Serialize};
use smallvec::SmallVec;
use std::boxed::FnBox;
use std::cell::{Cell, UnsafeCell};
use std::collections::{HashMap, HashSet};
use std::collections::{BTreeMap, HashMap, HashSet};
use std::ffi::CString;
use std::hash::{BuildHasher, Hash};
use std::intrinsics::return_address;
@ -246,6 +246,16 @@ impl<K, V, S> JSTraceable for HashMap<K, V, S>
}
}
impl<K: Ord + JSTraceable, V: JSTraceable> JSTraceable for BTreeMap<K, V> {
#[inline]
fn trace(&self, trc: *mut JSTracer) {
for (k, v) in self {
k.trace(trc);
v.trace(trc);
}
}
}
impl<A: JSTraceable, B: JSTraceable> JSTraceable for (A, B) {
#[inline]
fn trace(&self, trc: *mut JSTracer) {