]> 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 6b684c3055c9ea549555671e38911544628622cc..725506fa6fa5a8e4af653c9c647ff33ad020834e 100644 (file)
@@ -3,7 +3,7 @@
  *  Implementation of GiNaC's symmetry definitions. */
 
 /*
- *  GiNaC Copyright (C) 1999-2008 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2009 Johannes Gutenberg University Mainz, Germany
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include <iostream>
-#include <stdexcept>
-#include <functional>
-#include <limits>
-
 #include "symmetry.h"
 #include "lst.h"
 #include "numeric.h" // for factorial()
 #include "operators.h"
 #include "archive.h"
 #include "utils.h"
+#include "hash_seed.h"
+
+#include <functional>
+#include <iostream>
+#include <limits>
+#include <stdexcept>
 
 namespace GiNaC {
 
@@ -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)
                {