diff options
| author | Maxime Coste <mawww@kakoune.org> | 2024-02-28 19:00:51 +1100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2024-02-28 19:02:29 +1100 |
| commit | 3d5a0c672e6f3cf87944b33712e17531aa42c607 (patch) | |
| tree | d402461b8d6517072b27e653d1201888366718a8 /src/buffer_utils.cc | |
| parent | 57b794ede3cae1e7c21309869a2c617481a55acf (diff) | |
Templatize StringData::create
This improves performance by letting the compiler optimize most use
cases where string count and length are known are compile time.
Diffstat (limited to 'src/buffer_utils.cc')
| -rw-r--r-- | src/buffer_utils.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/buffer_utils.cc b/src/buffer_utils.cc index 996f6be5..effb7cc7 100644 --- a/src/buffer_utils.cc +++ b/src/buffer_utils.cc @@ -97,12 +97,12 @@ static BufferLines parse_lines(const char* pos, const char* end, EolFormat eolfo if ((eol - pos) >= std::numeric_limits<int>::max()) throw runtime_error("line is too long"); - lines.emplace_back(StringData::create({{pos, eol - (eolformat == EolFormat::Crlf and eol != end ? 1 : 0)}, "\n"})); + lines.emplace_back(StringData::create(StringView{pos, eol - (eolformat == EolFormat::Crlf and eol != end ? 1 : 0)}, "\n")); pos = eol + 1; } if (lines.empty()) - lines.emplace_back(StringData::create({"\n"})); + lines.emplace_back(StringData::create("\n")); return lines; } @@ -179,12 +179,12 @@ Buffer* create_fifo_buffer(String name, int fd, Buffer::Flags flags, bool scroll { buffer->flags() |= Buffer::Flags::NoUndo | flags; buffer->values().clear(); - buffer->reload({StringData::create({"\n"})}, ByteOrderMark::None, EolFormat::Lf, {InvalidTime, {}, {}}); + buffer->reload({StringData::create("\n")}, ByteOrderMark::None, EolFormat::Lf, {InvalidTime, {}, {}}); } else buffer = buffer_manager.create_buffer( std::move(name), flags | Buffer::Flags::Fifo | Buffer::Flags::NoUndo, - {StringData::create({"\n"})}, ByteOrderMark::None, EolFormat::Lf, {InvalidTime, {}, {}}); + {StringData::create("\n")}, ByteOrderMark::None, EolFormat::Lf, {InvalidTime, {}, {}}); struct FifoWatcher : FDWatcher { |
