X-Git-Url: https://ruin.nu/git/?p=popboot.git;a=blobdiff_plain;f=action.h;h=32fbcb986ad912d43b1c675d878f298ebce5eaf9;hp=a0a1173e4cc0ce9ff6507f615e8c911ed529bb7c;hb=921850c029bdaad568b0e40969b0805df785b72a;hpb=47c99f0a381056fb14d9871fc9f93536624df780 diff --git a/action.h b/action.h index a0a1173..32fbcb9 100644 --- a/action.h +++ b/action.h @@ -4,6 +4,7 @@ #include #include #include +#include typedef std::vector Literals; typedef __gnu_cxx::hash_map Preconditions; @@ -15,10 +16,9 @@ namespace __gnu_cxx { struct hash< std::basic_string > { size_t operator()(const std::basic_string& s) const { - size_t hash = 0; - for (unsigned int i = 0; i < s.size(); ++i) - hash += static_cast(s[i]); - return hash + s.size(); + const std::collate& c = std::use_facet< std::collate >(std::locale()); + + return c.hash(s.c_str(), s.c_str() + s.size()); } @@ -29,10 +29,9 @@ namespace __gnu_cxx { size_t operator()(const std::basic_string& s) const { - size_t hash = 0; - for (unsigned int i = 0; i < s.size(); ++i) - hash += static_cast(s[i]); - return hash + s.size(); + const std::collate& c = std::use_facet< std::collate >(std::locale()); + + return c.hash(s.c_str(), s.c_str() + s.size()); } };