private void InitPyWords(string tStr) { var lines = tStr.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); var wordPy = new List <ushort>(); List <string> keywords = new List <string>(); List <int> wordPyIndex = new List <int>(); wordPyIndex.Add(0); foreach (var line in lines) { var sp = line.Split(','); keywords.Add(sp[0]); for (int i = 1; i < sp.Length; i++) { var idx = sp[i]; wordPy.Add(ushort.Parse(idx, System.Globalization.NumberStyles.HexNumber)); } wordPyIndex.Add(wordPy.Count); } var search = new WordsSearchExBuild(); search.SetKeywords(keywords); _wordPyIndex = wordPyIndex.ToArray(); _wordPy = wordPy.ToArray(); _search = search; wordPy = null; keywords = null; wordPyIndex = null; }
private static void InitPyWords() { if (_search == null) { lock (lockObj) { if (_search == null) { byte[] bs = File.ReadAllBytes("dict\\pyWords.txt.br"); var bytes = Decompress(bs); var tStr = Encoding.UTF8.GetString(bytes); bytes = null; var lines = tStr.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); tStr = null; var wordPy = new List <ushort>(); List <string> keywords = new List <string>(); List <int> wordPyIndex = new List <int>(); wordPyIndex.Add(0); foreach (var line in lines) { var sp = line.Split(','); keywords.Add(sp[0]); for (int i = 1; i < sp.Length; i++) { var idx = sp[i]; wordPy.Add(ushort.Parse(idx, System.Globalization.NumberStyles.HexNumber)); } wordPyIndex.Add(wordPy.Count); } var search = new WordsSearchExBuild(); search.SetKeywords(keywords); _wordPyIndex = wordPyIndex.ToArray(); _wordPy = wordPy.ToArray(); _search = search; wordPy = null; keywords = null; wordPyIndex = null; } GC.Collect(); } } }