Store direct ref_ptr<StringStorage> for WordDB lines
Storing a SharedString is a waste, we want the whole line.
This commit is contained in:
parent
fb98ff652d
commit
cc699faa54
|
@ -126,8 +126,8 @@ public:
|
|||
StringView operator[](LineCount line) const
|
||||
{ return m_lines[line]; }
|
||||
|
||||
SharedString shared_line(LineCount line) const
|
||||
{ return m_lines.get_shared(line); }
|
||||
ref_ptr<StringStorage> line_storage(LineCount line) const
|
||||
{ return m_lines.get_storage(line); }
|
||||
|
||||
// returns an iterator at given coordinates. clamp line_and_column
|
||||
BufferIterator iterator_at(ByteCoord coord) const;
|
||||
|
@ -181,10 +181,6 @@ private:
|
|||
const ref_ptr<StringStorage>& get_storage(LineCount line) const
|
||||
{ return BufferLines::operator[]((int)line); }
|
||||
|
||||
[[gnu::always_inline]]
|
||||
SharedString get_shared(LineCount line) const
|
||||
{ return SharedString{get_storage(line)}; }
|
||||
|
||||
[[gnu::always_inline]]
|
||||
StringView operator[](LineCount line) const
|
||||
{ return get_storage(line)->strview(); }
|
||||
|
|
|
@ -80,8 +80,8 @@ WordDB::WordDB(const Buffer& buffer)
|
|||
m_lines.reserve((int)buffer.line_count());
|
||||
for (auto line = 0_line, end = buffer.line_count(); line < end; ++line)
|
||||
{
|
||||
m_lines.push_back(buffer[line]);
|
||||
add_words(get_words(m_lines.back()));
|
||||
m_lines.push_back(buffer.line_storage(line));
|
||||
add_words(get_words(SharedString{m_lines.back()}));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ void WordDB::update_db()
|
|||
while (old_line <= modif.old_line + modif.num_removed)
|
||||
{
|
||||
kak_assert(old_line < m_lines.size());
|
||||
remove_words(get_words(m_lines[(int)old_line++]));
|
||||
remove_words(get_words(SharedString{m_lines[(int)old_line++]}));
|
||||
}
|
||||
|
||||
for (auto l = 0_line; l <= modif.num_added; ++l)
|
||||
|
@ -119,8 +119,8 @@ void WordDB::update_db()
|
|||
if (modif.new_line + l >= buffer.line_count())
|
||||
break;
|
||||
|
||||
new_lines.push_back(buffer.shared_line(modif.new_line + l));
|
||||
add_words(get_words(new_lines.back()));
|
||||
new_lines.push_back(buffer.line_storage(modif.new_line + l));
|
||||
add_words(get_words(SharedString{new_lines.back()}));
|
||||
}
|
||||
}
|
||||
while (old_line != (int)m_lines.size())
|
||||
|
|
|
@ -50,7 +50,7 @@ private:
|
|||
int refcount;
|
||||
};
|
||||
using WordToInfo = UnorderedMap<SharedString, WordInfo, MemoryDomain::WordDB>;
|
||||
using Lines = Vector<SharedString, MemoryDomain::WordDB>;
|
||||
using Lines = Vector<ref_ptr<StringStorage>, MemoryDomain::WordDB>;
|
||||
|
||||
safe_ptr<const Buffer> m_buffer;
|
||||
size_t m_timestamp;
|
||||
|
|
Loading…
Reference in New Issue
Block a user