From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- Client/Assets/Scripts/XUtliPoolLib/UniqueString.cs | 76 ++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 Client/Assets/Scripts/XUtliPoolLib/UniqueString.cs (limited to 'Client/Assets/Scripts/XUtliPoolLib/UniqueString.cs') diff --git a/Client/Assets/Scripts/XUtliPoolLib/UniqueString.cs b/Client/Assets/Scripts/XUtliPoolLib/UniqueString.cs new file mode 100644 index 00000000..2554df55 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/UniqueString.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; + +namespace XUtliPoolLib +{ + public class UniqueString + { + private static Dictionary m_strings = new Dictionary(); + + public static string Intern(string str, bool removable = true) + { + bool flag = str == null; + string result; + if (flag) + { + result = null; + } + else + { + string text = UniqueString.IsInterned(str); + bool flag2 = text != null; + if (flag2) + { + result = text; + } + else if (removable) + { + UniqueString.m_strings.Add(str, str); + result = str; + } + else + { + result = string.Intern(str); + } + } + return result; + } + + public static string IsInterned(string str) + { + bool flag = str == null; + string result; + if (flag) + { + result = null; + } + else + { + string text = string.IsInterned(str); + bool flag2 = text != null; + if (flag2) + { + result = text; + } + else + { + bool flag3 = UniqueString.m_strings.TryGetValue(str, out text); + if (flag3) + { + result = text; + } + else + { + result = null; + } + } + } + return result; + } + + public static void Clear() + { + UniqueString.m_strings.Clear(); + } + } +} -- cgit v1.1-26-g67d0