]> www.ginac.de Git - ginac.git/blobdiff - ginac/symmetry.cpp
symmetry::calchash(): be careful to not dereference past-the-end iterator.
[ginac.git] / ginac / symmetry.cpp
index 1de84e644dd9d95737c3a0812dd544225f9f9d7b..725506fa6fa5a8e4af653c9c647ff33ad020834e 100644 (file)
@@ -26,6 +26,7 @@
 #include "operators.h"
 #include "archive.h"
 #include "utils.h"
+#include "hash_seed.h"
 
 #include <functional>
 #include <iostream>
@@ -185,12 +186,12 @@ int symmetry::compare_same_type(const basic & other) const
 
 unsigned symmetry::calchash() const
 {
-       const void* this_tinfo = (const void*)typeid(*this).name();
-       unsigned v = golden_ratio_hash((p_int)this_tinfo);
+       unsigned v = make_hash_seed(typeid(*this));
 
        if (type == none) {
                v = rotate_left(v);
-               v ^= *(indices.begin());
+               if (!indices.empty())
+                       v ^= *(indices.begin());
        } else {
                for (exvector::const_iterator i=children.begin(); i!=children.end(); ++i)
                {