summaryrefslogtreecommitdiff
path: root/src/string.hh
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2014-10-01 00:20:12 +0100
committerMaxime Coste <frrrwww@gmail.com>2014-10-01 00:20:12 +0100
commitd55d041c6aa9941cc74853e4b2bf6620773c84c1 (patch)
tree702ed4e245190845036d7523523fd0729ceeba81 /src/string.hh
parentd9e462851c4b18b80b478956ed20fb0be8a1d640 (diff)
Add support for interned strings
Use interned strings for Modification contents and word database. Interned strings are guaranteed not to move in memory and are reference counted.
Diffstat (limited to 'src/string.hh')
-rw-r--r--src/string.hh13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/string.hh b/src/string.hh
index 8f3df1a3..573853fe 100644
--- a/src/string.hh
+++ b/src/string.hh
@@ -140,6 +140,8 @@ inline bool StringView::operator!=(StringView other) const
return !this->operator==(other);
}
+bool operator<(StringView lhs, StringView rhs);
+
inline bool operator==(const char* lhs, StringView rhs)
{
return StringView{lhs} == rhs;
@@ -304,6 +306,8 @@ bool subsequence_match(StringView str, StringView subseq);
String expand_tabs(StringView line, CharCount tabstop, CharCount col = 0);
+size_t hash_data(const char* data, size_t len);
+
}
namespace std
@@ -316,6 +320,15 @@ namespace std
return hash<std::string>::operator()(str);
}
};
+
+ template<>
+ struct hash<Kakoune::StringView>
+ {
+ size_t operator()(Kakoune::StringView str) const
+ {
+ return Kakoune::hash_data(str.data(), (int)str.length());
+ }
+ };
}
#endif // string_hh_INCLUDED