MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Blast / generateIDFromString

Function generateIDFromString

samples/SampleBase/scene/SceneController.cpp:60–69  ·  view source on GitHub ↗

/// Simple hash function ////////

Source from the content-addressed store, hash-verified

58
59//////// Simple hash function ////////
60static NvBlastID generateIDFromString(const char* str)
61{
62 uint32_t h[4] = { 5381, 5381, 5381, 5381 };
63 int i = 0;
64 for (const char* ptr = str; *ptr; i = ((i + 1) & 3), ++ptr)
65 {
66 h[i] = ((h[i] << 5) + h[i]) ^ static_cast<uint32_t>(*ptr);
67 }
68 return *reinterpret_cast<NvBlastID*>(h);
69}
70
71
72///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Callers 2

spawnMethod · 0.85
spawnMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected