fix(node): use fxhasher for local signals/methods hashmaps
This commit is contained in:
@@ -1,15 +1,16 @@
|
|||||||
use crate::core::client::Client;
|
use crate::core::client::Client;
|
||||||
use crate::nodes::core::Node;
|
use crate::nodes::core::Node;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use core::hash::BuildHasherDefault;
|
|
||||||
use dashmap::DashMap;
|
|
||||||
use libstardustxr::scenegraph;
|
use libstardustxr::scenegraph;
|
||||||
use libstardustxr::scenegraph::ScenegraphError;
|
use libstardustxr::scenegraph::ScenegraphError;
|
||||||
use rccell::RcCell;
|
use rccell::RcCell;
|
||||||
use rustc_hash::FxHasher;
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::rc::{Rc, Weak};
|
use std::rc::{Rc, Weak};
|
||||||
|
|
||||||
|
use core::hash::BuildHasherDefault;
|
||||||
|
use dashmap::DashMap;
|
||||||
|
use rustc_hash::FxHasher;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Scenegraph<'a> {
|
pub struct Scenegraph<'a> {
|
||||||
client: RefCell<Weak<Client<'a>>>,
|
client: RefCell<Weak<Client<'a>>>,
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ use std::rc::{Rc, Weak};
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::{collections::HashMap, vec::Vec};
|
use std::{collections::HashMap, vec::Vec};
|
||||||
|
|
||||||
|
use core::hash::BuildHasherDefault;
|
||||||
|
use rustc_hash::FxHasher;
|
||||||
|
|
||||||
pub type Signal = fn(&Node, Rc<Client>, &[u8]) -> Result<()>;
|
pub type Signal = fn(&Node, Rc<Client>, &[u8]) -> Result<()>;
|
||||||
pub type Method = fn(&Node, Rc<Client>, &[u8]) -> Result<Vec<u8>>;
|
pub type Method = fn(&Node, Rc<Client>, &[u8]) -> Result<Vec<u8>>;
|
||||||
|
|
||||||
@@ -15,8 +18,8 @@ pub struct Node<'a> {
|
|||||||
client: Weak<Client<'a>>,
|
client: Weak<Client<'a>>,
|
||||||
path: String,
|
path: String,
|
||||||
// trailing_slash_pos: usize,
|
// trailing_slash_pos: usize,
|
||||||
local_signals: HashMap<String, Signal>,
|
local_signals: HashMap<String, Signal, BuildHasherDefault<FxHasher>>,
|
||||||
local_methods: HashMap<String, Method>,
|
local_methods: HashMap<String, Method, BuildHasherDefault<FxHasher>>,
|
||||||
destroyable: bool,
|
destroyable: bool,
|
||||||
|
|
||||||
pub spatial: Option<Rc<Spatial>>,
|
pub spatial: Option<Rc<Spatial>>,
|
||||||
@@ -46,8 +49,8 @@ impl<'a> Node<'a> {
|
|||||||
client,
|
client,
|
||||||
path,
|
path,
|
||||||
// trailing_slash_pos: parent.len(),
|
// trailing_slash_pos: parent.len(),
|
||||||
local_signals: HashMap::new(),
|
local_signals: Default::default(),
|
||||||
local_methods: HashMap::new(),
|
local_methods: Default::default(),
|
||||||
destroyable,
|
destroyable,
|
||||||
|
|
||||||
spatial: None,
|
spatial: None,
|
||||||
|
|||||||
Reference in New Issue
Block a user