summaryrefslogtreecommitdiff
path: root/src/buffer.cc
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2016-02-05 00:20:45 +0000
committerMaxime Coste <frrrwww@gmail.com>2016-02-05 00:20:45 +0000
commitff6eacffa3f5bb10e0bf0d31b3eabc7ac10fcd51 (patch)
tree2248f19174e82af9cf9796a375e848d232f7b685 /src/buffer.cc
parenta8eddd03f0e328b08d23ec9f83c5c61e9a9b202a (diff)
dont intern SharedStrings but StringDataPtr
Diffstat (limited to 'src/buffer.cc')
-rw-r--r--src/buffer.cc14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/buffer.cc b/src/buffer.cc
index cd014574..e140f333 100644
--- a/src/buffer.cc
+++ b/src/buffer.cc
@@ -199,9 +199,9 @@ struct Buffer::Modification
Type type;
ByteCoord coord;
- SharedString content;
+ StringDataPtr content;
- Modification(Type type, ByteCoord coord, SharedString content)
+ Modification(Type type, ByteCoord coord, StringDataPtr content)
: type(type), coord(coord), content(std::move(content)) {}
Modification inverse() const
@@ -248,7 +248,7 @@ void Buffer::reload(StringView data, timespec fs_timestamp)
for (LineCount line = 0; line < d.len; ++line)
m_current_undo_group.emplace_back(
Modification::Insert, cur_line + line,
- SharedString{parsed_lines.lines[(int)(d.posB + line)]});
+ parsed_lines.lines[(int)(d.posB + line)]);
m_changes.push_back({ Change::Insert, it == m_lines.end(), cur_line, cur_line + d.len });
m_lines.insert(it, &parsed_lines.lines[d.posB], &parsed_lines.lines[d.posB + d.len]);
@@ -261,7 +261,7 @@ void Buffer::reload(StringView data, timespec fs_timestamp)
for (LineCount line = d.len-1; line >= 0; --line)
m_current_undo_group.emplace_back(
Modification::Erase, cur_line + line,
- SharedString{m_lines.get_storage(cur_line + line)});
+ m_lines.get_storage(cur_line + line));
it = m_lines.erase(it, it + d.len);
m_changes.push_back({ Change::Erase, it == m_lines.end(), cur_line, cur_line + d.len });
@@ -433,7 +433,7 @@ ByteCoord Buffer::do_erase(ByteCoord begin, ByteCoord end)
void Buffer::apply_modification(const Modification& modification)
{
- StringView content = modification.content;
+ StringView content = modification.content->strview();
ByteCoord coord = modification.coord;
kak_assert(is_valid(coord));
@@ -467,7 +467,7 @@ BufferIterator Buffer::insert(const BufferIterator& pos, StringView content)
if (content.empty())
return pos;
- SharedString real_content;
+ StringDataPtr real_content;
if (pos == end() and content.back() != '\n')
real_content = intern(content + "\n");
else
@@ -478,7 +478,7 @@ BufferIterator Buffer::insert(const BufferIterator& pos, StringView content)
auto coord = pos == end() ? ByteCoord{line_count()} : pos.coord();
if (not (m_flags & Flags::NoUndo))
m_current_undo_group.emplace_back(Modification::Insert, coord, real_content);
- return {*this, do_insert(pos.coord(), real_content)};
+ return {*this, do_insert(pos.coord(), real_content->strview())};
}
BufferIterator Buffer::erase(BufferIterator begin, BufferIterator end)