From 3068dfdc5b4431eda0cc47c3263b137856906b99 Mon Sep 17 00:00:00 2001 From: Lol3rrr Date: Mon, 30 Sep 2024 15:51:52 +0200 Subject: [PATCH] Switch to using Arc for often cloned strings --- src/parser.rs | 4 ++-- src/parser/entities.rs | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index ba18a7c..5e95029 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -107,7 +107,7 @@ struct GameEventMapping { #[derive(Debug)] pub struct Class { - name: String, + name: std::sync::Arc, serializer: sendtables::Serializer, } @@ -241,7 +241,7 @@ where entity_ctx.cls_to_class.insert( cls_id as u32, Class { - name: network_name.to_owned(), + name: network_name.into(), serializer: ser, }, ); diff --git a/src/parser/entities.rs b/src/parser/entities.rs index 307cf42..0b57fc4 100644 --- a/src/parser/entities.rs +++ b/src/parser/entities.rs @@ -1,5 +1,7 @@ use super::{decoder, propcontroller, Class, Entity, FirstPassError, Paths}; +use std::sync::Arc; + pub struct EntityContext { pub entities: std::collections::HashMap, pub cls_to_class: std::collections::HashMap, @@ -9,7 +11,7 @@ pub struct EntityContext { #[derive(Debug, Clone)] pub struct EntityState { pub id: i32, - pub class: String, + pub class: Arc, pub cls: u32, pub props: Vec, } @@ -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); }