summaryrefslogtreecommitdiff
path: root/src/buffer_utils.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2024-02-28 19:00:51 +1100
committerMaxime Coste <mawww@kakoune.org>2024-02-28 19:02:29 +1100
commit3d5a0c672e6f3cf87944b33712e17531aa42c607 (patch)
treed402461b8d6517072b27e653d1201888366718a8 /src/buffer_utils.cc
parent57b794ede3cae1e7c21309869a2c617481a55acf (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.cc8
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
{