add: new graph cmd: "stats", now accessible through cmd, not only via menu.

fix: changed language string hashes to reduce collisions.
This commit is contained in:
ds 2020-08-31 14:52:12 +03:00
commit eadd7cd3a2
6 changed files with 72 additions and 51 deletions

View file

@ -766,13 +766,21 @@ const char *BotConfig::translate (StringRef input) {
uint32 BotConfig::hashLangString (const char *input) {
auto str = reinterpret_cast <uint8 *> (const_cast <char *> (input));
uint32 hash = 0;
uint32_t hash = 0;
while (*str++) {
for (; *str; ++str) {
if (!isalnum (*str)) {
continue;
}
hash = ((*str << 5) + hash) + *str;
hash += *str;
hash += (hash << 10);
hash ^= (hash >> 6);
}
hash += (hash << 3);
hash ^= (hash >> 11);
hash += (hash << 15);
return hash;
}