]> www.ginac.de Git - ginac.git/blobdiff - ginac/hash_seed.h
Finalize 1.7.6 release.
[ginac.git] / ginac / hash_seed.h
index 32b057fba4671090624e81432ed9b7d44bbda447..9b163cf86010952ab40289682763657228842ef2 100644 (file)
@@ -1,5 +1,23 @@
+/** @file hash_seed.h
+ *
+ * Type-specific hash seed. */
+
 #ifndef GINAC_HASH_SEED_H
 #define GINAC_HASH_SEED_H
+
+#include <typeinfo>
+#include <cstring>
+#include "utils.h"
+#ifdef _WIN32
+#define GINAC_HASH_USE_MANGLED_NAME 1
+#endif
+
+#ifdef GINAC_HASH_USE_MANGLED_NAME
+#include "crc32.h"
+#endif
+
+namespace GiNaC
+{
 /**
  * We need a hash function which gives different values for objects of
  * different types. Hence we need some unique integer for each type.
  * the pointer returned by type_info::name() might be different even for
  * objects of the same type! Hence we need to resort to comparing string
  * representation of the (mangled) type names. This is quite expensive,
- * so we compare crc32 hashes of those strings. We might got more hash
+ * so we compare crc32 hashes of those strings. We might get more hash
  * collisions (and slower evaluation as a result), but being a bit slower
  * is much better than being wrong.
  */
-#include <typeinfo>
-#include <cstring>
-#include "crc32.h"
-#include "utils.h"
-#ifdef _WIN32
-#define GINAC_HASH_USE_MANGLED_NAME 1
-#endif
-namespace GiNaC
-{
 #ifndef GINAC_HASH_USE_MANGLED_NAME
 static inline unsigned make_hash_seed(const std::type_info& tinfo)
 {
-       // this pointer is the same for all objects of the same type.
-       // Hence we can use that pointer 
+       // This pointer is the same for all objects of the same type.
+       // Hence we can use it.
        const void* mangled_name_ptr = (const void*)tinfo.name();
-       unsigned v = golden_ratio_hash((p_int)mangled_name_ptr);
+       unsigned v = golden_ratio_hash((uintptr_t)mangled_name_ptr);
        return v;
 }
 #else