summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2015-03-10 13:50:25 +0000
committerMaxime Coste <frrrwww@gmail.com>2015-03-10 13:50:25 +0000
commita0cf75ec39c679776b28b178a4299cf0ad204a1c (patch)
tree53f1878ef4f3caec77e34586fcdaf8431eadeee0 /src
parentea526c2137d6efcf2b93b2958f2811c056f925a7 (diff)
Tweak WordDB implementation
Diffstat (limited to 'src')
-rw-r--r--src/word_db.cc14
-rw-r--r--src/word_db.hh4
2 files changed, 9 insertions, 9 deletions
diff --git a/src/word_db.cc b/src/word_db.cc
index 4ddc69ee..2ca11dba 100644
--- a/src/word_db.cc
+++ b/src/word_db.cc
@@ -52,9 +52,9 @@ static WordDB::WordList get_words(const SharedString& content)
return res;
}
-void WordDB::add_words(const WordList& words)
+void WordDB::add_words(const SharedString& line)
{
- for (auto& w : words)
+ for (auto& w : get_words(line))
{
WordDB::WordInfo& info = m_words[intern(w)];
++info.refcount;
@@ -63,9 +63,9 @@ void WordDB::add_words(const WordList& words)
}
}
-void WordDB::remove_words(const WordList& words)
+void WordDB::remove_words(const SharedString& line)
{
- for (auto& w : words)
+ for (auto& w : get_words(line))
{
auto it = m_words.find({w, SharedString::NoCopy()});
kak_assert(it != m_words.end() and it->second.refcount > 0);
@@ -81,7 +81,7 @@ WordDB::WordDB(const Buffer& buffer)
for (auto line = 0_line, end = buffer.line_count(); line < end; ++line)
{
m_lines.push_back(buffer.line_storage(line));
- add_words(get_words(SharedString{m_lines.back()}));
+ add_words(SharedString{m_lines.back()});
}
}
@@ -112,13 +112,13 @@ void WordDB::update_db()
while (old_line < modif.old_line + modif.num_removed)
{
kak_assert(old_line < m_lines.size());
- remove_words(get_words(SharedString{m_lines[(int)old_line++]}));
+ remove_words(SharedString{m_lines[(int)old_line++]});
}
for (auto l = 0_line; l < modif.num_added; ++l)
{
new_lines.push_back(buffer.line_storage(modif.new_line + l));
- add_words(get_words(SharedString{new_lines.back()}));
+ add_words(SharedString{new_lines.back()});
}
}
while (old_line != (int)m_lines.size())
diff --git a/src/word_db.hh b/src/word_db.hh
index 71cc5c3e..ad0dbadc 100644
--- a/src/word_db.hh
+++ b/src/word_db.hh
@@ -41,8 +41,8 @@ public:
int get_word_occurences(StringView word) const;
private:
void update_db();
- void add_words(const WordList& words);
- void remove_words(const WordList& words);
+ void add_words(const SharedString& line);
+ void remove_words(const SharedString& line);
struct WordInfo
{