diff options
Diffstat (limited to 'Client/Assets/Scripts/XUtliPoolLib/UniqueString.cs')
-rw-r--r-- | Client/Assets/Scripts/XUtliPoolLib/UniqueString.cs | 76 |
1 files changed, 76 insertions, 0 deletions
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<string, string> m_strings = new Dictionary<string, string>();
+
+ 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();
+ }
+ }
+}
|