mirror of
https://github.com/servo/servo.git
synced 2025-09-27 23:30:08 +01:00
Moves to FxHashMap for Allocator, BHM, Canvas, Media, Servo, WebGL and WebGPU (#39202)
This moves more of HashMap/FnvHashMap to FxHashmap. Again we only changed instances that do not look security related and have small keys. Additionally, allocator used the fnv feature which did not seem to be used. Testing: Unit Tests and WPT should cover this and functionality change is highly unlikely. Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
This commit is contained in:
parent
228b240635
commit
d2c78db981
19 changed files with 53 additions and 46 deletions
|
@ -11,12 +11,12 @@ rust-version.workspace = true
|
|||
path = "lib.rs"
|
||||
|
||||
[features]
|
||||
allocation-tracking = ["backtrace", "fnv"]
|
||||
allocation-tracking = ["backtrace", "dep:rustc-hash"]
|
||||
use-system-allocator = ["libc"]
|
||||
|
||||
[dependencies]
|
||||
backtrace = { workspace = true, optional = true }
|
||||
fnv = { workspace = true, optional = true }
|
||||
rustc-hash = { workspace = true, optional = true }
|
||||
|
||||
[target.'cfg(not(any(windows, target_env = "ohos")))'.dependencies]
|
||||
libc = { workspace = true, optional = true }
|
||||
|
|
|
@ -12,7 +12,7 @@ use std::collections::hash_map::Entry;
|
|||
use std::os::raw::c_void;
|
||||
use std::sync::Mutex;
|
||||
|
||||
use fnv::{FnvBuildHasher, FnvHashMap};
|
||||
use rustc_hash::{FxBuildHasher, FxHashMap};
|
||||
|
||||
/// The maximum number of allocations that we'll keep track of. Once the limit
|
||||
/// is reached, we'll evict the first allocation that is smaller than the new addition.
|
||||
|
@ -54,8 +54,8 @@ impl AllocSite {
|
|||
unsafe impl Send for AllocSite {}
|
||||
|
||||
/// A map of pointers to allocation callsite metadata.
|
||||
static ALLOCATION_SITES: Mutex<FnvHashMap<usize, AllocSite>> =
|
||||
const { Mutex::new(FnvHashMap::with_hasher(FnvBuildHasher::new())) };
|
||||
static ALLOCATION_SITES: Mutex<FxHashMap<usize, AllocSite>> =
|
||||
const { Mutex::new(FxHashMap::default()) };
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct AccountingAlloc<A = System> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue