diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2014-10-01 00:20:12 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2014-10-01 00:20:12 +0100 |
| commit | d55d041c6aa9941cc74853e4b2bf6620773c84c1 (patch) | |
| tree | 702ed4e245190845036d7523523fd0729ceeba81 /src/buffer.cc | |
| parent | d9e462851c4b18b80b478956ed20fb0be8a1d640 (diff) | |
Add support for interned strings
Use interned strings for Modification contents and word database.
Interned strings are guaranteed not to move in memory and are
reference counted.
Diffstat (limited to 'src/buffer.cc')
| -rw-r--r-- | src/buffer.cc | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/buffer.cc b/src/buffer.cc index 7c7a4e63..aa6314d6 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -2,11 +2,12 @@ #include "assert.hh" #include "buffer_manager.hh" +#include "client.hh" #include "context.hh" #include "file.hh" +#include "interned_string.hh" #include "utils.hh" #include "window.hh" -#include "client.hh" #include <algorithm> @@ -170,9 +171,9 @@ struct Buffer::Modification Type type; ByteCoord coord; - String content; + InternedString content; - Modification(Type type, ByteCoord coord, String content) + Modification(Type type, ByteCoord coord, InternedString content) : type(type), coord(coord), content(std::move(content)) {} Modification inverse() const @@ -240,7 +241,7 @@ void Buffer::check_invariant() const #endif } -ByteCoord Buffer::do_insert(ByteCoord pos, const String& content) +ByteCoord Buffer::do_insert(ByteCoord pos, StringView content) { kak_assert(is_valid(pos)); @@ -341,7 +342,7 @@ ByteCoord Buffer::do_erase(ByteCoord begin, ByteCoord end) void Buffer::apply_modification(const Modification& modification) { - const String& content = modification.content; + StringView content = modification.content; ByteCoord coord = modification.coord; kak_assert(is_valid(coord)); |
