From 33a80e644ccf19d1059363ac0555148e7bff6e3d Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 21 Aug 2021 16:42:08 +1000 Subject: Take a function SelectionList::insert to get string to insert This makes it unnecessary to allocate Vector to insert and allows to remove the insert_pos pointer hack by passing it to the callback. --- src/string.hh | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/string.hh') diff --git a/src/string.hh b/src/string.hh index 6fa425e5..d14929f4 100644 --- a/src/string.hh +++ b/src/string.hh @@ -124,6 +124,8 @@ public: struct NoCopy{}; String(NoCopy, StringView str); + static String no_copy(StringView str); + [[gnu::always_inline]] char* data() { return m_data.data(); } @@ -274,6 +276,7 @@ template<> struct HashCompatible : std::true_type {}; inline String::String(StringView str) : String{str.begin(), str.length()} {} inline String::String(NoCopy, StringView str) : m_data{NoCopy{}, str.begin(), (size_t)str.length()} {} +inline String String::no_copy(StringView str) { return {NoCopy{}, str}; } template inline StringView StringOps::substr(ByteCount from, ByteCount length) const -- cgit v1.2.3