From: Michael Andreen Date: Wed, 1 Jun 2005 09:09:51 +0000 (+0000) Subject: simple hash X-Git-Url: https://ruin.nu/git/?p=popboot.git;a=commitdiff_plain;h=47c99f0a381056fb14d9871fc9f93536624df780 simple hash --- diff --git a/action.h b/action.h index 606857d..a0a1173 100644 --- a/action.h +++ b/action.h @@ -15,9 +15,10 @@ namespace __gnu_cxx { struct hash< std::basic_string > { size_t operator()(const std::basic_string& s) const { - const std::collate& c = std::use_facet< std::collate >(std::locale()); - - return c.hash(s.c_str(), s.c_str() + s.size()); + size_t hash = 0; + for (unsigned int i = 0; i < s.size(); ++i) + hash += static_cast(s[i]); + return hash + s.size(); } @@ -28,9 +29,10 @@ namespace __gnu_cxx { size_t operator()(const std::basic_string& s) const { - const std::collate& c = std::use_facet< std::collate >(std::locale()); - - return c.hash(s.c_str(), s.c_str() + s.size()); + size_t hash = 0; + for (unsigned int i = 0; i < s.size(); ++i) + hash += static_cast(s[i]); + return hash + s.size(); } };