mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
vector reserve the size to reduce reallocation
This commit is contained in:
parent
39a7c85303
commit
9a708bfd81
|
@ -1117,6 +1117,11 @@ void IndexedWords::addWord( wstring const & word, uint32_t articleOffset, unsign
|
|||
|
||||
if( ( i->second.size() < 1024 ) || ( nextChar == wordBegin ) ) // Don't overpopulate chains with middle matches
|
||||
{
|
||||
// reduce the vector reallocation.
|
||||
if( i->second.size() * 1.0 / i->second.capacity() > 0.75 )
|
||||
{
|
||||
i->second.reserve( i->second.capacity() * 2 );
|
||||
}
|
||||
string utfWord = Utf8::encode( wstring( nextChar, wordSize - ( nextChar - wordBegin ) ) );
|
||||
|
||||
string utfPrefix = Utf8::encode( wstring( wordBegin, nextChar - wordBegin ) );
|
||||
|
|
Loading…
Reference in a new issue