| 25 | using namespace opencc; |
| 26 | |
| 27 | static size_t GetKeyMaxLength(const LexiconPtr& lexicon) { |
| 28 | size_t maxLength = 0; |
| 29 | for (const auto& entry : *lexicon) { |
| 30 | size_t keyLength = entry->KeyLength(); |
| 31 | maxLength = (std::max)(keyLength, maxLength); |
| 32 | } |
| 33 | return maxLength; |
| 34 | } |
| 35 | |
| 36 | TextDict::TextDict(const LexiconPtr& _lexicon) |
| 37 | : maxLength(GetKeyMaxLength(_lexicon)), lexicon(_lexicon) { |