summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XUtliPoolLib/UniqueString.cs
blob: 2554df55e1d3de3187402e25d50ff0d23701fedc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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();
		}
	}
}