Skip to content

Commit c72c775

Browse files
committed
Changing the djbHash namespace.
1 parent 28ad5de commit c72c775

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/core/psxemulator.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ void PCSX::Emulator::setLua() {
9090
return L.error("t_ expects a string");
9191
}
9292
auto str = L.tostring(1);
93-
L.push(g_system->getStr(djbHash::hash(str), str.c_str()));
93+
L.push(g_system->getStr(djb::hash(str), str.c_str()));
9494
return 1;
9595
});
9696
L.load("ffi = require('ffi')", "internal:setffi.lua");

src/core/system.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ bool PCSX::System::loadLocale(const std::string& name, const std::filesystem::pa
232232
if (!currentString.empty() && !fuzzy) locale[hashValue] = currentString;
233233
break;
234234
case WAITING_MSGSTRTOKEN:
235-
hashValue = djbHash::hash(currentString);
235+
hashValue = djb::hash(currentString);
236236
break;
237237
}
238238
currentString = "";

src/core/system.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,8 @@ extern System *g_system;
291291

292292
// i18n macros
293293
// Normal string lookup to const char *
294-
#define _(str) PCSX::g_system->getStr(PCSX::djbHash::ctHash(str), str)
294+
#define _(str) PCSX::g_system->getStr(PCSX::djb::ctHash(str), str)
295295
// Formatting string lookup to use with fmt::format or fmt::printf
296-
#define f_(str) fmt::runtime(PCSX::g_system->getStr(PCSX::djbHash::ctHash(str), str))
296+
#define f_(str) fmt::runtime(PCSX::g_system->getStr(PCSX::djb::ctHash(str), str))
297297
// Lambda string lookup to use with static arrays of strings
298-
#define l_(str) []() { return PCSX::g_system->getStr(PCSX::djbHash::ctHash(str), str); }
298+
#define l_(str) []() { return PCSX::g_system->getStr(PCSX::djb::ctHash(str), str); }

src/support/djbhash.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ SOFTWARE.
3232

3333
namespace PCSX {
3434

35-
struct djbHash {
35+
struct djb {
3636
private:
37-
static inline constexpr uint64_t djbProcess(uint64_t hash, const char str[], size_t n) {
38-
return n ? djbProcess(((hash << 5) + hash) ^ str[0], str + 1, n - 1) : hash;
37+
static inline constexpr uint64_t process(uint64_t hash, const char str[], size_t n) {
38+
return n ? process(((hash << 5) + hash) ^ static_cast<uint8_t>(str[0]), str + 1, n - 1) : hash;
3939
}
4040

4141
public:
4242
template <size_t S>
4343
static inline constexpr uint64_t ctHash(const char (&str)[S]) {
44-
return djbProcess(5381, str, S - 1);
44+
return process(5381, str, S - 1);
4545
}
46-
static inline constexpr uint64_t hash(const char *str, size_t n) { return djbProcess(5381, str, n); }
47-
static inline uint64_t hash(const std::string &str) { return djbProcess(5381, str.c_str(), str.length()); }
46+
static inline constexpr uint64_t hash(const char *str, size_t n) { return process(5381, str, n); }
47+
static inline uint64_t hash(const std::string &str) { return process(5381, str.c_str(), str.length()); }
4848
};
4949

5050
} // namespace PCSX

0 commit comments

Comments
 (0)