Refactor WordDB::add_words to be slightly faster
This commit is contained in:
parent
d9abc2a156
commit
a39f2b0c71
|
@ -46,16 +46,14 @@ void WordDB::add_words(StringView line)
|
||||||
for (auto& w : get_words(line, get_extra_word_chars(*m_buffer)))
|
for (auto& w : get_words(line, get_extra_word_chars(*m_buffer)))
|
||||||
{
|
{
|
||||||
auto it = m_words.find(w);
|
auto it = m_words.find(w);
|
||||||
if (it == m_words.end())
|
if (it != m_words.end())
|
||||||
|
++it->second.refcount;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
auto word = intern(w);
|
auto word = intern(w);
|
||||||
WordDB::WordInfo& info = m_words[word->strview()];
|
auto view = word->strview();
|
||||||
info.word = word;
|
m_words.insert({view, {std::move(word), used_letters(view), 1}});
|
||||||
info.letters = used_letters(w);
|
|
||||||
++info.refcount;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
++ it->second.refcount;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user