mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
perf(core): use BTreeMap for GothamState (#10073)
This commit replaces GothamState's internal HashMap with a BTreeMap to improve performance. OpState/GothamState keys by TypeId which is essentially an opaque u64. For small sets of integer keys BTreeMap outperforms HashMap mainly since it removes the hashing overhead and Eq/Comp on integer-like types is very cheap, it should also have a smaller memory footprint. We only use ~30 unique types and thus ~30 unique keys to access OpState, so the keyset is small and immutable throughout the life of a JsRuntime, there's no meaningful churn in keys added/removed.
This commit is contained in:
parent
c86ee742a2
commit
0b4cb29386
1 changed files with 2 additions and 2 deletions
|
@ -6,11 +6,11 @@
|
|||
use log::trace;
|
||||
use std::any::Any;
|
||||
use std::any::TypeId;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct GothamState {
|
||||
data: HashMap<TypeId, Box<dyn Any>>,
|
||||
data: BTreeMap<TypeId, Box<dyn Any>>,
|
||||
}
|
||||
|
||||
impl GothamState {
|
||||
|
|
Loading…
Reference in a new issue