mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-30 17:24:08 +00:00
divide by zero
This commit is contained in:
parent
d95f545b70
commit
20a4220a01
11
btreeidx.cc
11
btreeidx.cc
|
@ -1117,16 +1117,17 @@ 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()+1) > 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 ) );
|
||||
|
||||
i->second.emplace_back(utfWord, articleOffset, utfPrefix);
|
||||
// reduce the vector reallocation.
|
||||
if( i->second.size() * 1.0 / i->second.capacity() > 0.75 )
|
||||
{
|
||||
i->second.reserve( i->second.capacity() * 2 );
|
||||
}
|
||||
}
|
||||
|
||||
wordsAdded += 1;
|
||||
|
|
Loading…
Reference in a new issue