|
GiNaC
1.6.2
|
00001 #ifndef GINAC_HASH_SEED_H 00002 #define GINAC_HASH_SEED_H 00003 00017 #include <typeinfo> 00018 #include <cstring> 00019 #include "crc32.h" 00020 #include "utils.h" 00021 #ifdef _WIN32 00022 #define GINAC_HASH_USE_MANGLED_NAME 1 00023 #endif 00024 namespace GiNaC 00025 { 00026 #ifndef GINAC_HASH_USE_MANGLED_NAME 00027 static inline unsigned make_hash_seed(const std::type_info& tinfo) 00028 { 00029 // this pointer is the same for all objects of the same type. 00030 // Hence we can use that pointer 00031 const void* mangled_name_ptr = (const void*)tinfo.name(); 00032 unsigned v = golden_ratio_hash((p_int)mangled_name_ptr); 00033 return v; 00034 } 00035 #else 00036 static unsigned make_hash_seed(const std::type_info& tinfo) 00037 { 00038 const char* mangled_name = tinfo.name(); 00039 return crc32(mangled_name, std::strlen(mangled_name), 0); 00040 } 00041 #endif 00042 } // namespace GiNaC 00043 #endif /* GINAC_HASH_SEED_H */ 00044 00045