summaryrefslogtreecommitdiff
path: root/src/string.hh
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-03-06 19:47:26 +0000
committerMaxime Coste <mawww@kakoune.org>2017-03-06 22:25:08 +0000
commit420373475e9f8c4a2c3b570ee3c528090fa2ce49 (patch)
tree3d28a2d62387aa26478629ecfdfa3b21f32d4e98 /src/string.hh
parent6757ddc6cbc0b585549099d1a1850ec836bcebb0 (diff)
Introduce a custom HashMap implementation along with a quick benchmark
Diffstat (limited to 'src/string.hh')
-rw-r--r--src/string.hh11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/string.hh b/src/string.hh
index 14e92bd7..6c0a467e 100644
--- a/src/string.hh
+++ b/src/string.hh
@@ -121,6 +121,8 @@ public:
}
String(const char* begin, const char* end) : m_data(begin, end-begin) {}
+ explicit String(StringView str);
+
[[gnu::always_inline]]
char* data() { return m_data.data(); }
@@ -254,6 +256,10 @@ private:
static_assert(std::is_trivial<StringView>::value, "");
+template<> struct HashCompatible<String, StringView> : std::true_type {};
+
+inline String::String(StringView str) : String{str.begin(), str.length()} {}
+
template<typename Type, typename CharType>
inline StringView StringOps<Type, CharType>::substr(ByteCount from, ByteCount length) const
{
@@ -319,6 +325,11 @@ inline String operator"" _str(const char* str, size_t)
return String(str);
}
+inline StringView operator"" _sv(const char* str, size_t)
+{
+ return StringView{str};
+}
+
Vector<String> split(StringView str, char separator, char escape);
Vector<StringView> split(StringView str, char separator);