MCPcopy Create free account
hub / github.com/cinder/Cinder / ImHashData

Function ImHashData

src/imgui/imgui.cpp:2324–2344  ·  view source on GitHub ↗

Known size hash It is ok to call ImHashData on a string with known length but the ### operator won't be supported. FIXME-OPT: Replace with e.g. FNV1a hash? CRC32 pretty much randomly access 1KB. Need to do proper measurements.

Source from the content-addressed store, hash-verified

2322// It is ok to call ImHashData on a string with known length but the ### operator won't be supported.
2323// FIXME-OPT: Replace with e.g. FNV1a hash? CRC32 pretty much randomly access 1KB. Need to do proper measurements.
2324ImGuiID ImHashData(const void* data_p, size_t data_size, ImGuiID seed)
2325{
2326 ImU32 crc = ~seed;
2327 const unsigned char* data = (const unsigned char*)data_p;
2328 const unsigned char *data_end = (const unsigned char*)data_p + data_size;
2329#ifndef IMGUI_ENABLE_SSE4_2_CRC
2330 const ImU32* crc32_lut = GCrc32LookupTable;
2331 while (data < data_end)
2332 crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ *data++];
2333 return ~crc;
2334#else
2335 while (data + 4 <= data_end)
2336 {
2337 crc = _mm_crc32_u32(crc, *(ImU32*)data);
2338 data += 4;
2339 }
2340 while (data < data_end)
2341 crc = _mm_crc32_u8(crc, *data++);
2342 return ~crc;
2343#endif
2344}
2345
2346// Zero-terminated string hash, with support for ### to reset back to seed value
2347// We support a syntax of "label###id" where only "###id" is included in the hash, and only "label" gets displayed.

Callers 7

GetIDMethod · 0.85
GetIDFromPosMethod · 0.85
GetIDFromRectangleMethod · 0.85
GetIDWithSeedMethod · 0.85
ImFontAtlasBakedGetIdFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected