divide by zero

This commit is contained in:
Xiao YiFang 2022-08-12 21:41:17 +08:00
parent d95f545b70
commit 20a4220a01

View file

@ -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;