replace hash fn

This commit is contained in:
blueloveTH 2022-12-31 04:01:05 +08:00
parent fcdff94be3
commit f3ccd1c7d1
5 changed files with 8 additions and 6 deletions

View File

@ -23,6 +23,9 @@
#include <atomic> #include <atomic>
#include <iostream> #include <iostream>
#define EMH_WYHASH_HASH 1
#include "hash_table8.hpp"
#ifdef POCKETPY_H #ifdef POCKETPY_H
#define UNREACHABLE() throw std::runtime_error( "L" + std::to_string(__LINE__) + " UNREACHABLE()! This should be a bug, please report it"); #define UNREACHABLE() throw std::runtime_error( "L" + std::to_string(__LINE__) + " UNREACHABLE()! This should be a bug, please report it");
#else #else

View File

@ -1660,7 +1660,7 @@ one-way search strategy.
#if EMH_WYHASH_HASH #if EMH_WYHASH_HASH
//#define WYHASH_CONDOM 1 //#define WYHASH_CONDOM 1
inline uint64_t wymix(uint64_t A, uint64_t B) inline static uint64_t wymix(uint64_t A, uint64_t B)
{ {
#if defined(__SIZEOF_INT128__) #if defined(__SIZEOF_INT128__)
__uint128_t r = A; r *= B; __uint128_t r = A; r *= B;

View File

@ -3,8 +3,8 @@
#include "pocketpy.h" #include "pocketpy.h"
//#define PK_DEBUG_TIME #define PK_DEBUG_TIME
#define PK_DEBUG_THREADED //#define PK_DEBUG_THREADED
struct Timer{ struct Timer{
const char* title; const char* title;

View File

@ -36,8 +36,6 @@ public:
}; };
#include "hash_table8.hpp"
class PyVarDict: public emhash8::HashMap<_Str, PyVar> { class PyVarDict: public emhash8::HashMap<_Str, PyVar> {
using emhash8::HashMap<_Str, PyVar>::HashMap; using emhash8::HashMap<_Str, PyVar>::HashMap;
}; };

View File

@ -46,7 +46,8 @@ public:
size_t hash() const{ size_t hash() const{
if(!hash_initialized){ if(!hash_initialized){
_hash = std::hash<std::string>()(*this); //_hash = std::hash<std::string>()(*this);
_hash = emhash8::HashMap<int,int>::wyhashstr(data(), size());
hash_initialized = true; hash_initialized = true;
} }
return _hash; return _hash;