コード例 #1
0
ファイル: ProtoReader.cs プロジェクト: ilynx/ilynx.common
        private string Intern(string value)
        {
            if (value == null)
            {
                return(null);
            }
            if (value.Length == 0)
            {
                return(string.Empty);
            }
            string found;

            if (stringInterner == null)
            {
                stringInterner = new System.Collections.Generic.Dictionary <string, string>();
                stringInterner.Add(value, value);
            }
            else if (stringInterner.TryGetValue(value, out found))
            {
                value = found;
            }
            else
            {
                stringInterner.Add(value, value);
            }
            return(value);
        }