|
@@ -2368,11 +2368,8 @@ ImGuiID ImHashData(const void* data_p, size_t data_size, ImGuiID seed)
|
|
|
#endif
|
|
#endif
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// Zero-terminated string hash, with support for ### to reset back to seed value
|
|
|
|
|
-// We support a syntax of "label###id" where only "###id" is included in the hash, and only "label" gets displayed.
|
|
|
|
|
-// Because this syntax is rarely used we are optimizing for the common case.
|
|
|
|
|
-// - If we reach ### in the string we discard the hash so far and reset to the seed.
|
|
|
|
|
-// - We don't do 'current += 2; continue;' after handling ### to keep the code smaller/faster (measured ~10% diff in Debug build)
|
|
|
|
|
|
|
+// Zero-terminated string hash, with support for ### to reset back to seed value.
|
|
|
|
|
+// e.g. "label###id" outputs the same hash as "id" (and "label" is generally displayed by the UI functions)
|
|
|
// FIXME-OPT: Replace with e.g. FNV1a hash? CRC32 pretty much randomly access 1KB. Need to do proper measurements.
|
|
// FIXME-OPT: Replace with e.g. FNV1a hash? CRC32 pretty much randomly access 1KB. Need to do proper measurements.
|
|
|
ImGuiID ImHashStr(const char* data_p, size_t data_size, ImGuiID seed)
|
|
ImGuiID ImHashStr(const char* data_p, size_t data_size, ImGuiID seed)
|
|
|
{
|
|
{
|
|
@@ -2384,11 +2381,16 @@ ImGuiID ImHashStr(const char* data_p, size_t data_size, ImGuiID seed)
|
|
|
#endif
|
|
#endif
|
|
|
if (data_size != 0)
|
|
if (data_size != 0)
|
|
|
{
|
|
{
|
|
|
- while (data_size-- != 0)
|
|
|
|
|
|
|
+ while (data_size-- > 0)
|
|
|
{
|
|
{
|
|
|
unsigned char c = *data++;
|
|
unsigned char c = *data++;
|
|
|
if (c == '#' && data_size >= 2 && data[0] == '#' && data[1] == '#')
|
|
if (c == '#' && data_size >= 2 && data[0] == '#' && data[1] == '#')
|
|
|
|
|
+ {
|
|
|
crc = seed;
|
|
crc = seed;
|
|
|
|
|
+ data += 2;
|
|
|
|
|
+ data_size -= 2;
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
#ifndef IMGUI_ENABLE_SSE4_2_CRC
|
|
#ifndef IMGUI_ENABLE_SSE4_2_CRC
|
|
|
crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c];
|
|
crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c];
|
|
|
#else
|
|
#else
|
|
@@ -2401,7 +2403,11 @@ ImGuiID ImHashStr(const char* data_p, size_t data_size, ImGuiID seed)
|
|
|
while (unsigned char c = *data++)
|
|
while (unsigned char c = *data++)
|
|
|
{
|
|
{
|
|
|
if (c == '#' && data[0] == '#' && data[1] == '#')
|
|
if (c == '#' && data[0] == '#' && data[1] == '#')
|
|
|
|
|
+ {
|
|
|
crc = seed;
|
|
crc = seed;
|
|
|
|
|
+ data += 2;
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
#ifndef IMGUI_ENABLE_SSE4_2_CRC
|
|
#ifndef IMGUI_ENABLE_SSE4_2_CRC
|
|
|
crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c];
|
|
crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c];
|
|
|
#else
|
|
#else
|
|
@@ -2419,7 +2425,7 @@ const char* ImHashSkipUncontributingPrefix(const char* label)
|
|
|
const char* result = label;
|
|
const char* result = label;
|
|
|
while (unsigned char c = *label++)
|
|
while (unsigned char c = *label++)
|
|
|
if (c == '#' && label[0] == '#' && label[1] == '#')
|
|
if (c == '#' && label[0] == '#' && label[1] == '#')
|
|
|
- result = label - 1;
|
|
|
|
|
|
|
+ result = label + 2;
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|