summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2021-07-09 17:03:22 +1000
committerMaxime Coste <mawww@kakoune.org>2021-07-09 17:03:22 +1000
commitc30a0e0ca27aa93db65fb9d2399a596eeb610b6d (patch)
treecfeff974d2b9cfc8fa539f523170b6f0c87ee3af
parent2289f350df1b957f0fbd60ecc941a87d4d7b4b44 (diff)
Inline String::Data no-copy constructor
-rw-r--r--src/string.cc7
-rw-r--r--src/string.hh3
2 files changed, 2 insertions, 8 deletions
diff --git a/src/string.cc b/src/string.cc
index b5f04f29..37467451 100644
--- a/src/string.cc
+++ b/src/string.cc
@@ -6,13 +6,6 @@
namespace Kakoune
{
-String::Data::Data(String::NoCopy, const char* data, size_t size)
-{
- l.ptr = const_cast<char*>(data);
- l.size = size;
- l.capacity = 0;
-}
-
String::Data::Data(const char* data, size_t size, size_t capacity)
{
if (capacity > Short::capacity)
diff --git a/src/string.hh b/src/string.hh
index 56771c65..1a3568e0 100644
--- a/src/string.hh
+++ b/src/string.hh
@@ -178,7 +178,8 @@ public:
} s;
Data() { set_empty(); }
- Data(NoCopy, const char* data, size_t size);
+ Data(NoCopy, const char* data, size_t size) : l{const_cast<char*>(data), size, 0} {}
+
Data(const char* data, size_t size, size_t capacity);
Data(const char* data, size_t size) : Data(data, size, size) {}
Data(const Data& other) : Data{other.data(), other.size()} {}