MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / ImHashData

Function ImHashData

Source/3rdParty/imgui/imgui.cpp:2414–2434  ·  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

2412// It is ok to call ImHashData on a string with known length but the ### operator won't be supported.
2413// FIXME-OPT: Replace with e.g. FNV1a hash? CRC32 pretty much randomly access 1KB. Need to do proper measurements.
2414ImGuiID ImHashData(const void* data_p, size_t data_size, ImGuiID seed)
2415{
2416 ImU32 crc = ~seed;
2417 const unsigned char* data = (const unsigned char*)data_p;
2418 const unsigned char *data_end = (const unsigned char*)data_p + data_size;
2419#ifndef IMGUI_ENABLE_SSE4_2_CRC
2420 const ImU32* crc32_lut = GCrc32LookupTable;
2421 while (data < data_end)
2422 crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ *data++];
2423 return ~crc;
2424#else
2425 while (data + 4 <= data_end)
2426 {
2427 crc = _mm_crc32_u32(crc, *(ImU32*)data);
2428 data += 4;
2429 }
2430 while (data < data_end)
2431 crc = _mm_crc32_u8(crc, *data++);
2432 return ~crc;
2433#endif
2434}
2435
2436// Zero-terminated string hash, with support for ### to reset back to seed value.
2437// e.g. "label###id" outputs the same hash as "id" (and "label" is generally displayed by the UI functions)

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