| 369 | } |
| 370 | |
| 371 | staticfn void |
| 372 | add_glyph_to_cache(int glyphnum, const char *id) |
| 373 | { |
| 374 | uint32 hash = glyph_hash(id); |
| 375 | size_t hash1 = (size_t) (hash & (glyphid_cache_size - 1)); |
| 376 | size_t hash2 = (size_t) |
| 377 | (((hash >> glyphid_cache_lsize) & (glyphid_cache_size - 1)) | 1); |
| 378 | size_t i = hash1; |
| 379 | |
| 380 | do { |
| 381 | if (glyphid_cache[i].id == NULL) { |
| 382 | /* Empty bucket found */ |
| 383 | glyphid_cache[i].id = dupstr(id); |
| 384 | glyphid_cache[i].glyphnum = glyphnum; |
| 385 | return; |
| 386 | } |
| 387 | /* For speed, assume that no ID occurs twice */ |
| 388 | i = (i + hash2) & (glyphid_cache_size - 1); |
| 389 | } while (i != hash1); |
| 390 | /* This should never happen */ |
| 391 | panic("glyphid_cache full"); |
| 392 | } |
| 393 | |
| 394 | staticfn int |
| 395 | find_glyph_in_cache(const char *id) |
no test coverage detected