diff --git a/src/buffer.hh b/src/buffer.hh index 9963b7cc..084af636 100644 --- a/src/buffer.hh +++ b/src/buffer.hh @@ -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 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& 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(); } diff --git a/src/word_db.cc b/src/word_db.cc index 1332dd3c..6b0eeb0a 100644 --- a/src/word_db.cc +++ b/src/word_db.cc @@ -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()) diff --git a/src/word_db.hh b/src/word_db.hh index 8034560f..81955068 100644 --- a/src/word_db.hh +++ b/src/word_db.hh @@ -50,7 +50,7 @@ private: int refcount; }; using WordToInfo = UnorderedMap; - using Lines = Vector; + using Lines = Vector, MemoryDomain::WordDB>; safe_ptr m_buffer; size_t m_timestamp;