diff --git a/src/DictTrie.hpp b/src/DictTrie.hpp index 729364cc..6d9ed04d 100644 --- a/src/DictTrie.hpp +++ b/src/DictTrie.hpp @@ -80,6 +80,7 @@ namespace CppJieba { assert(!_getInitFlag()); _loadDict(filePath, _nodeInfos); + _shrink(_nodeInfos); _freqSum = _calculateFreqSum(_nodeInfos); assert(_freqSum); _minLogFreq = _calculateLogFreqAndGetMinValue(_nodeInfos, _freqSum); @@ -114,6 +115,7 @@ namespace CppJieba words.push_back(dictUnits[i].word); valuePointers.push_back(&dictUnits[i]); } + TrieType * trie = new TrieType(words, valuePointers); return trie; } @@ -172,6 +174,11 @@ namespace CppJieba return minLogFreq; } + void _shrink(vector& units) const + { + vector(units.begin(), units.end()).swap(units); + } + }; }