From 0ca119be70d7799014d32725cd5a8a708fac86de Mon Sep 17 00:00:00 2001 From: ALEXTANG <574809918@qq.com> Date: Mon, 8 Aug 2022 19:21:25 +0800 Subject: [PATCH] Update StringId.cs --- Assets/TEngine/Runtime/Event/StringId.cs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Assets/TEngine/Runtime/Event/StringId.cs b/Assets/TEngine/Runtime/Event/StringId.cs index 880adf62..3264ce03 100644 --- a/Assets/TEngine/Runtime/Event/StringId.cs +++ b/Assets/TEngine/Runtime/Event/StringId.cs @@ -4,29 +4,27 @@ namespace TEngine { public class StringId { - private static Dictionary m_eventTypeHashMap = new Dictionary(); - private static Dictionary m_eventHashToStringMap = new Dictionary(); - private static int m_currentId = 0; + private static readonly Dictionary eventTypeHashMap = new Dictionary(); + private static readonly Dictionary eventHashToStringMap = new Dictionary(); + private static int _currentId = 0; public static int StringToHash(string val) { - int hashId; - if (m_eventTypeHashMap.TryGetValue(val, out hashId)) + if (eventTypeHashMap.TryGetValue(val, out var hashId)) { return hashId; } - hashId = ++m_currentId; - m_eventTypeHashMap[val] = hashId; - m_eventHashToStringMap[hashId] = val; + hashId = ++_currentId; + eventTypeHashMap[val] = hashId; + eventHashToStringMap[hashId] = val; return hashId; } public static string HashToString(int hash) { - string value; - if (m_eventHashToStringMap.TryGetValue(hash, out value)) + if (eventHashToStringMap.TryGetValue(hash, out var value)) { return value; }