diff --git a/src/lib/symbol-impl.cpp b/src/lib/symbol-impl.cpp index 232dba4ac..8645bf544 100644 --- a/src/lib/symbol-impl.cpp +++ b/src/lib/symbol-impl.cpp @@ -95,18 +95,17 @@ namespace lib { } - /** generating a hash value, e.g. for hashtables. - This function is intended to be picked up by ADL, - and should be usable both with \c std::tr1 and - \c . It is implemented - similar as the boost::hash specialisation for std::string */ + /** generate hash value based on the Literal's contents. + * This function is intended to be picked up by ADL, and should be usable + * both with `std::hash` and ``. It is implemented + * similar as the boost::hash specialisation for std::string */ size_t - hash_value (Literal sym) + hash_value (Literal literal) { size_t hash=0; - if (sym) + if (literal) { - const char *pos = sym; + const char *pos = literal; size_t maxpos = STRING_MAX_RELEVANT; for ( ; *pos && --maxpos; ++pos) hash_combine(hash, *pos); @@ -115,6 +114,14 @@ namespace lib { return hash; } + /** hash value for Symbols is directly based on the symbol table entry */ + size_t + hash_value (Symbol sym) + { + return sym? boost::hash_value (sym.c()) + : 0; + } + } // namespace lib diff --git a/src/lib/symbol.hpp b/src/lib/symbol.hpp index f94ec2e5c..d844e8f21 100644 --- a/src/lib/symbol.hpp +++ b/src/lib/symbol.hpp @@ -138,6 +138,7 @@ namespace lib { /* ===== to be picked up by ADL ===== */ size_t hash_value (Literal); + size_t hash_value (Symbol); /* === equality comparisons === */