From ebecd60eb810246cfa682a1fbd72270aa9861f0b Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 16 Dec 2014 18:57:19 +0000 Subject: Rework hashing, use a more extensible framework similar to n3876 proposal std::hash specialization is a pain to work with, stop using that, and just specialize a 'size_t hash_value(const T&)' free function. --- src/string.hh | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'src/string.hh') diff --git a/src/string.hh b/src/string.hh index eefe6985..afab4486 100644 --- a/src/string.hh +++ b/src/string.hh @@ -3,6 +3,7 @@ #include "units.hh" #include "utf8.hh" +#include "hash.hh" #include #include @@ -267,29 +268,16 @@ String expand_tabs(StringView line, CharCount tabstop, CharCount col = 0); std::vector wrap_lines(StringView text, CharCount max_width); -size_t hash_data(const char* data, size_t len); - +inline size_t hash_value(const Kakoune::String& str) +{ + return hash_data(str.data(), (int)str.length()); } -namespace std +inline size_t hash_value(const Kakoune::StringView& str) { - template<> - struct hash : hash - { - size_t operator()(const Kakoune::String& str) const - { - return hash::operator()(str); - } - }; + return hash_data(str.data(), (int)str.length()); +} - template<> - struct hash - { - size_t operator()(Kakoune::StringView str) const - { - return Kakoune::hash_data(str.data(), (int)str.length()); - } - }; } #endif // string_hh_INCLUDED -- cgit v1.2.3