diff options
| author | Maxime Coste <mawww@kakoune.org> | 2021-08-21 16:42:08 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2021-08-30 16:14:26 +1000 |
| commit | 33a80e644ccf19d1059363ac0555148e7bff6e3d (patch) | |
| tree | 5a70631697ac1ea7af3199f857e0676115f59311 /src/string.hh | |
| parent | bc11f972c53cbf445972e726e9e908f9e1929892 (diff) | |
Take a function SelectionList::insert to get string to insert
This makes it unnecessary to allocate Vector<String> to insert and
allows to remove the insert_pos pointer hack by passing it to the
callback.
Diffstat (limited to 'src/string.hh')
| -rw-r--r-- | src/string.hh | 3 |
1 files changed, 3 insertions, 0 deletions
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<StringView, String> : 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<typename Type, typename CharType> inline StringView StringOps<Type, CharType>::substr(ByteCount from, ByteCount length) const |
