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.
| 2292 | // It is ok to call ImHashData on a string with known length but the ### operator won't be supported. |
| 2293 | // FIXME-OPT: Replace with e.g. FNV1a hash? CRC32 pretty much randomly access 1KB. Need to do proper measurements. |
| 2294 | ImGuiID ImHashData(const void* data_p, size_t data_size, ImGuiID seed) |
| 2295 | { |
| 2296 | ImU32 crc = ~seed; |
| 2297 | const unsigned char* data = (const unsigned char*)data_p; |
| 2298 | const unsigned char *data_end = (const unsigned char*)data_p + data_size; |
| 2299 | #ifndef IMGUI_ENABLE_SSE4_2_CRC |
| 2300 | const ImU32* crc32_lut = GCrc32LookupTable; |
| 2301 | while (data < data_end) |
| 2302 | crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ *data++]; |
| 2303 | return ~crc; |
| 2304 | #else |
| 2305 | while (data + 4 <= data_end) |
| 2306 | { |
| 2307 | crc = _mm_crc32_u32(crc, *(ImU32*)data); |
| 2308 | data += 4; |
| 2309 | } |
| 2310 | while (data < data_end) |
| 2311 | crc = _mm_crc32_u8(crc, *data++); |
| 2312 | return ~crc; |
| 2313 | #endif |
| 2314 | } |
| 2315 | |
| 2316 | // Zero-terminated string hash, with support for ### to reset back to seed value |
| 2317 | // We support a syntax of "label###id" where only "###id" is included in the hash, and only "label" gets displayed. |
no outgoing calls
no test coverage detected