Use B-tree collections instead of Fx hash ones
This removes a dependency. Since the collections in question should usually be pretty small, it might also reduce memory overhead at little cost in speed. Here are some relevant performance discussions: https://users.rust-lang.org/t/hashmap-vs-btreemap/13804 https://www.reddit.com/r/rust/comments/7rgowj/hashmap_vs_btreemap/
This commit is contained in:
parent
c6b628d424
commit
501cd74c96
4 changed files with 6 additions and 16 deletions
7
app-proto/Cargo.lock
generated
7
app-proto/Cargo.lock
generated
|
@ -89,7 +89,6 @@ dependencies = [
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"nalgebra",
|
"nalgebra",
|
||||||
"readonly",
|
"readonly",
|
||||||
"rustc-hash",
|
|
||||||
"sycamore",
|
"sycamore",
|
||||||
"wasm-bindgen-test",
|
"wasm-bindgen-test",
|
||||||
"web-sys",
|
"web-sys",
|
||||||
|
@ -364,12 +363,6 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustc-hash"
|
|
||||||
version = "2.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "safe_arch"
|
name = "safe_arch"
|
||||||
version = "0.7.2"
|
version = "0.7.2"
|
||||||
|
|
|
@ -15,7 +15,6 @@ js-sys = "0.3.70"
|
||||||
lazy_static = "1.5.0"
|
lazy_static = "1.5.0"
|
||||||
nalgebra = "0.33.0"
|
nalgebra = "0.33.0"
|
||||||
readonly = "0.2.12"
|
readonly = "0.2.12"
|
||||||
rustc-hash = "2.0.0"
|
|
||||||
sycamore = "0.9.0-beta.3"
|
sycamore = "0.9.0-beta.3"
|
||||||
|
|
||||||
# The `console_error_panic_hook` crate provides better debugging of panics by
|
# The `console_error_panic_hook` crate provides better debugging of panics by
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
use nalgebra::{DMatrix, DVector, DVectorView};
|
use nalgebra::{DMatrix, DVector, DVectorView};
|
||||||
use rustc_hash::FxHashMap;
|
|
||||||
use std::{
|
use std::{
|
||||||
any::{Any, TypeId},
|
any::{Any, TypeId},
|
||||||
cell::Cell,
|
cell::Cell,
|
||||||
collections::BTreeSet,
|
collections::{BTreeMap, BTreeSet},
|
||||||
cmp::Ordering,
|
cmp::Ordering,
|
||||||
fmt,
|
fmt,
|
||||||
fmt::{Debug, Formatter},
|
fmt::{Debug, Formatter},
|
||||||
|
@ -522,7 +521,7 @@ pub struct Assembly {
|
||||||
pub tangent: Signal<ConfigSubspace>,
|
pub tangent: Signal<ConfigSubspace>,
|
||||||
|
|
||||||
// indexing
|
// indexing
|
||||||
pub elements_by_id: Signal<FxHashMap<String, Rc<dyn Element>>>
|
pub elements_by_id: Signal<BTreeMap<String, Rc<dyn Element>>>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Assembly {
|
impl Assembly {
|
||||||
|
@ -531,7 +530,7 @@ impl Assembly {
|
||||||
elements: create_signal(BTreeSet::new()),
|
elements: create_signal(BTreeSet::new()),
|
||||||
regulators: create_signal(BTreeSet::new()),
|
regulators: create_signal(BTreeSet::new()),
|
||||||
tangent: create_signal(ConfigSubspace::zero(0)),
|
tangent: create_signal(ConfigSubspace::zero(0)),
|
||||||
elements_by_id: create_signal(FxHashMap::default())
|
elements_by_id: create_signal(BTreeMap::default())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,7 @@ mod specified;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
use rustc_hash::FxHashSet;
|
use std::{collections::BTreeSet, rc::Rc};
|
||||||
use std::rc::Rc;
|
|
||||||
use sycamore::prelude::*;
|
use sycamore::prelude::*;
|
||||||
|
|
||||||
use add_remove::AddRemove;
|
use add_remove::AddRemove;
|
||||||
|
@ -20,14 +19,14 @@ use outline::Outline;
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct AppState {
|
struct AppState {
|
||||||
assembly: Assembly,
|
assembly: Assembly,
|
||||||
selection: Signal<FxHashSet<Rc<dyn Element>>>
|
selection: Signal<BTreeSet<Rc<dyn Element>>>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppState {
|
impl AppState {
|
||||||
fn new() -> AppState {
|
fn new() -> AppState {
|
||||||
AppState {
|
AppState {
|
||||||
assembly: Assembly::new(),
|
assembly: Assembly::new(),
|
||||||
selection: create_signal(FxHashSet::default())
|
selection: create_signal(BTreeSet::default())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue