mirror of
https://github.com/servo/servo.git
synced 2025-09-30 00:29:14 +01:00
Removed FnvHash and transformed the rest to FxHashmap (#39233)
This should be the final PR for the Hash Function series that is trivial. Of note: I decided to transform `HashMapTracedValues<Atom,..>` to use FxBuildHasher. This is likely not going to improve performance as Atom's already have a unique u32 that is used as the Hash but it safes a few bytes for the RandomState that is normally in the HashMap. Signed-off-by: Narfinger <Narfinger@users.noreply.github.com> Testing: Hash function changes should not change functionality, we slightly decrease the size and unit tests still work. Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
This commit is contained in:
parent
726b456120
commit
84465e7768
55 changed files with 211 additions and 202 deletions
|
@ -15,6 +15,7 @@ use js::jsapi::{HandleValueArray, Heap, IsCallable, IsConstructor, JSAutoRealm,
|
|||
use js::jsval::{BooleanValue, JSVal, NullValue, ObjectValue, UndefinedValue};
|
||||
use js::rust::wrappers::{Construct1, JS_GetProperty, SameValue};
|
||||
use js::rust::{HandleObject, MutableHandleValue};
|
||||
use rustc_hash::FxBuildHasher;
|
||||
use script_bindings::conversions::{SafeFromJSValConvertible, SafeToJSValConvertible};
|
||||
|
||||
use super::bindings::trace::HashMapTracedValues;
|
||||
|
@ -68,12 +69,15 @@ pub(crate) struct CustomElementRegistry {
|
|||
window: Dom<Window>,
|
||||
|
||||
#[ignore_malloc_size_of = "Rc"]
|
||||
when_defined: DomRefCell<HashMapTracedValues<LocalName, Rc<Promise>>>,
|
||||
/// It is safe to use FxBuildHasher here as `LocalName` is an `Atom` in the string_cache.
|
||||
/// These get a u32 hashed instead of a string.
|
||||
when_defined: DomRefCell<HashMapTracedValues<LocalName, Rc<Promise>, FxBuildHasher>>,
|
||||
|
||||
element_definition_is_running: Cell<bool>,
|
||||
|
||||
#[ignore_malloc_size_of = "Rc"]
|
||||
definitions: DomRefCell<HashMapTracedValues<LocalName, Rc<CustomElementDefinition>>>,
|
||||
definitions:
|
||||
DomRefCell<HashMapTracedValues<LocalName, Rc<CustomElementDefinition>, FxBuildHasher>>,
|
||||
}
|
||||
|
||||
impl CustomElementRegistry {
|
||||
|
@ -81,9 +85,9 @@ impl CustomElementRegistry {
|
|||
CustomElementRegistry {
|
||||
reflector_: Reflector::new(),
|
||||
window: Dom::from_ref(window),
|
||||
when_defined: DomRefCell::new(HashMapTracedValues::new()),
|
||||
when_defined: DomRefCell::new(HashMapTracedValues::new_fx()),
|
||||
element_definition_is_running: Cell::new(false),
|
||||
definitions: DomRefCell::new(HashMapTracedValues::new()),
|
||||
definitions: DomRefCell::new(HashMapTracedValues::new_fx()),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue