From fd72f42c92c28ca52f89b555913acf6ed1bc161f Mon Sep 17 00:00:00 2001 From: hyzboy Date: Sat, 7 Jun 2025 04:30:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=81=A2=E5=A4=8D=E7=94=A8size=5Ft=E5=81=9A?= =?UTF-8?q?=E4=B8=BAidname=E7=9A=84=E7=B4=A2=E5=BC=95.=E5=9B=A0=E4=B8=BA?= =?UTF-8?q?=E6=88=91=E4=BB=AC=E7=9A=84=E7=B4=A2=E5=BC=95=E6=98=AF=E7=94=A8?= =?UTF-8?q?hash=5Fcode=E4=BA=A7=E7=94=9F=E7=9A=84=EF=BC=8C=E4=BC=A0?= =?UTF-8?q?=E5=85=A5=E5=AD=97=E7=AC=A6=E4=B8=B2=E5=90=8D=E5=AD=97=E5=8F=AA?= =?UTF-8?q?=E6=98=AF=E4=B8=BA=E8=AE=A9=E4=BA=86typeid().hash=5Fcode()?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E4=B8=8D=E4=B8=80=E6=A0=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/hgl/type/IDName.h | 4 ++-- src/Type/IDName.cpp | 12 +++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/inc/hgl/type/IDName.h b/inc/hgl/type/IDName.h index 5aec4ea..4caa3ad 100644 --- a/inc/hgl/type/IDName.h +++ b/inc/hgl/type/IDName.h @@ -6,7 +6,7 @@ namespace hgl { template - bool RegistryIDName(const char *IDNameTag,ConstStringView &csv,const SC *name_string,const int name_length); + bool RegistryIDName(const size_t hash_code,ConstStringView &csv,const SC *name_string,const int name_length); /** * 顺序ID+名称数据结构模板
@@ -39,7 +39,7 @@ namespace hgl return; } - RegistryIDName(IDNAME_TAG,csv,name_string,name_length); + RegistryIDName(typeid(SelfClass).hash_code(),csv,name_string,name_length); } public: diff --git a/src/Type/IDName.cpp b/src/Type/IDName.cpp index 974f8af..234efce 100644 --- a/src/Type/IDName.cpp +++ b/src/Type/IDName.cpp @@ -3,24 +3,22 @@ namespace hgl { template - bool RegistryIDName(const char *tag,ConstStringView &csv,const SC *name_string,const int name_length) + bool RegistryIDName(const size_t hash_code,ConstStringView &csv,const SC *name_string,const int name_length) { - static ObjectMap> css_map; + static ObjectMap> css_map; ConstStringSet *css; - const AnsiString IDNameTag=tag; - - if(!css_map.Get(IDNameTag,css)) + if(!css_map.Get(hash_code,css)) { css=new ConstStringSet; - css_map.Add(IDNameTag,css); + css_map.Add(hash_code,css); } return(css->AddString(csv,name_string,name_length)>=0); } -#define REGISTRY_ID_NAME(type) bool RegistryIDName_##type(const char *tag,ConstStringView &csv,const type *name,const int length){return RegistryIDName(tag,csv,name,length);} +#define REGISTRY_ID_NAME(type) bool RegistryIDName_##type(const size_t hash_code,ConstStringView &csv,const type *name,const int length){return RegistryIDName(hash_code,csv,name,length);} REGISTRY_ID_NAME(char) REGISTRY_ID_NAME(wchar_t)