Commit f9dfa874 authored by nanahira's avatar nanahira

rehash for genesys

parent 1274720b
Pipeline #42956 failed with stages
in 6 minutes and 29 seconds
...@@ -13,6 +13,17 @@ void DeckManager::LoadLFListFromLineProvider(const std::function<bool(char*, siz ...@@ -13,6 +13,17 @@ void DeckManager::LoadLFListFromLineProvider(const std::function<bool(char*, siz
auto cur = loadedLists.rend(); auto cur = loadedLists.rend();
char linebuf[256]{}; char linebuf[256]{};
wchar_t strBuffer[256]{}; wchar_t strBuffer[256]{};
auto credit_hash = [](const char* s) -> uint32_t {
uint32_t h = 2166136261u;
for(const unsigned char* p = reinterpret_cast<const unsigned char*>(s); *p; ++p) {
h ^= *p;
h *= 16777619u;
}
return h;
};
auto credit_update_hash = [](uint32_t& h, uint32_t a, uint32_t b, uint32_t c) {
h = h ^ ((a << 18) | (a >> 14)) ^ ((b << 9) | (b >> 23)) ^ ((c << 27) | (c >> 5));
};
if(true) { if(true) {
while(getLine(linebuf, sizeof linebuf)) { while(getLine(linebuf, sizeof linebuf)) {
if(linebuf[0] == '#') if(linebuf[0] == '#')
...@@ -50,6 +61,7 @@ void DeckManager::LoadLFListFromLineProvider(const std::function<bool(char*, siz ...@@ -50,6 +61,7 @@ void DeckManager::LoadLFListFromLineProvider(const std::function<bool(char*, siz
continue; continue;
BufferIO::DecodeUTF8(keybuf, strBuffer); BufferIO::DecodeUTF8(keybuf, strBuffer);
cur->credit_limits[strBuffer] = static_cast<uint32_t>(limitValue); cur->credit_limits[strBuffer] = static_cast<uint32_t>(limitValue);
credit_update_hash(cur->hash, credit_hash(keybuf), static_cast<uint32_t>(limitValue), 0x43524544u);
continue; continue;
} }
char* pos = linebuf; char* pos = linebuf;
...@@ -82,6 +94,7 @@ void DeckManager::LoadLFListFromLineProvider(const std::function<bool(char*, siz ...@@ -82,6 +94,7 @@ void DeckManager::LoadLFListFromLineProvider(const std::function<bool(char*, siz
continue; continue;
BufferIO::DecodeUTF8(keybuf, strBuffer); BufferIO::DecodeUTF8(keybuf, strBuffer);
cur->credits[code][strBuffer] = static_cast<uint32_t>(creditValue); cur->credits[code][strBuffer] = static_cast<uint32_t>(creditValue);
credit_update_hash(cur->hash, code, credit_hash(keybuf), static_cast<uint32_t>(creditValue));
continue; continue;
} }
errno = 0; errno = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment