MCPcopy Create free account
hub / github.com/NetHack/NetHack / find_glyph_in_cache

Function find_glyph_in_cache

src/glyphs.c:394–415  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

392}
393
394staticfn int
395find_glyph_in_cache(const char *id)
396{
397 uint32 hash = glyph_hash(id);
398 size_t hash1 = (size_t) (hash & (glyphid_cache_size - 1));
399 size_t hash2 = (size_t)
400 (((hash >> glyphid_cache_lsize) & (glyphid_cache_size - 1)) | 1);
401 size_t i = hash1;
402
403 do {
404 if (glyphid_cache[i].id == NULL) {
405 /* Empty bucket found */
406 return -1;
407 }
408 if (strcmpi(id, glyphid_cache[i].id) == 0) {
409 /* Match found */
410 return glyphid_cache[i].glyphnum;
411 }
412 i = (i + hash2) & (glyphid_cache_size - 1);
413 } while (i != hash1);
414 return -1;
415}
416
417staticfn char *
418find_glyphid_in_cache_by_glyphnum(int glyphnum)

Callers 1

parse_idFunction · 0.85

Calls 1

glyph_hashFunction · 0.85

Tested by

no test coverage detected