mirror of
https://github.com/servo/servo.git
synced 2025-09-30 08:39:16 +01:00
Replace Hash Algorithm in HashMap/Set with FxHashMap/Set for simple types (#39166)
FxHash is faster than FnvHash and SipHash for simple types up to at least 64 bytes. The cryptographic guarantees are not needed for any types changed here because they are simple ids. This changes the types in script and net crates. In a future PR we will change the remaining Fnv to be also Fx unless there is a reason to keep them as Fnv. Testing: Should not change functionality but unit test and wpt will find it. Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
This commit is contained in:
parent
1deb7b5957
commit
177f6d6502
46 changed files with 226 additions and 215 deletions
|
@ -3,7 +3,6 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::collections::HashMap;
|
||||
use std::rc::Rc;
|
||||
|
||||
use canvas_traits::webgl::{GLContextAttributes, WebGLVersion};
|
||||
|
@ -19,6 +18,7 @@ use js::error::throw_type_error;
|
|||
use js::rust::{HandleObject, HandleValue};
|
||||
use layout_api::HTMLCanvasData;
|
||||
use pixels::{EncodedImageType, Snapshot};
|
||||
use rustc_hash::FxHashMap;
|
||||
use script_bindings::weakref::WeakRef;
|
||||
use servo_media::streams::MediaStreamType;
|
||||
use servo_media::streams::registry::MediaStreamId;
|
||||
|
@ -77,7 +77,7 @@ pub(crate) struct HTMLCanvasElement {
|
|||
// This id and hashmap are used to keep track of ongoing toBlob() calls.
|
||||
callback_id: Cell<u32>,
|
||||
#[ignore_malloc_size_of = "not implemented for webidl callbacks"]
|
||||
blob_callbacks: RefCell<HashMap<u32, Rc<BlobCallback>>>,
|
||||
blob_callbacks: RefCell<FxHashMap<u32, Rc<BlobCallback>>>,
|
||||
}
|
||||
|
||||
impl HTMLCanvasElement {
|
||||
|
@ -90,7 +90,7 @@ impl HTMLCanvasElement {
|
|||
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
|
||||
context_mode: DomRefCell::new(None),
|
||||
callback_id: Cell::new(0),
|
||||
blob_callbacks: RefCell::new(HashMap::new()),
|
||||
blob_callbacks: RefCell::new(FxHashMap::default()),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue