Switch to using Arc<str> for often cloned strings
This commit is contained in:
@@ -107,7 +107,7 @@ struct GameEventMapping {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Class {
|
pub struct Class {
|
||||||
name: String,
|
name: std::sync::Arc<str>,
|
||||||
serializer: sendtables::Serializer,
|
serializer: sendtables::Serializer,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,7 +241,7 @@ where
|
|||||||
entity_ctx.cls_to_class.insert(
|
entity_ctx.cls_to_class.insert(
|
||||||
cls_id as u32,
|
cls_id as u32,
|
||||||
Class {
|
Class {
|
||||||
name: network_name.to_owned(),
|
name: network_name.into(),
|
||||||
serializer: ser,
|
serializer: ser,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
use super::{decoder, propcontroller, Class, Entity, FirstPassError, Paths};
|
use super::{decoder, propcontroller, Class, Entity, FirstPassError, Paths};
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub struct EntityContext {
|
pub struct EntityContext {
|
||||||
pub entities: std::collections::HashMap<i32, Entity>,
|
pub entities: std::collections::HashMap<i32, Entity>,
|
||||||
pub cls_to_class: std::collections::HashMap<u32, Class>,
|
pub cls_to_class: std::collections::HashMap<u32, Class>,
|
||||||
@@ -9,7 +11,7 @@ pub struct EntityContext {
|
|||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct EntityState {
|
pub struct EntityState {
|
||||||
pub id: i32,
|
pub id: i32,
|
||||||
pub class: String,
|
pub class: Arc<str>,
|
||||||
pub cls: u32,
|
pub cls: u32,
|
||||||
pub props: Vec<EntityProp>,
|
pub props: Vec<EntityProp>,
|
||||||
}
|
}
|
||||||
@@ -98,7 +100,7 @@ impl EntityContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !(self.filter.entity)(class.name.as_str()) {
|
if !(self.filter.entity)(class.name.as_ref()) {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user