diff options
| author | Stefan Monnier | 2024-01-24 14:52:09 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2024-01-24 14:52:31 -0500 |
| commit | ad004f10f3668d464d32ed8da18639da9bcc01bb (patch) | |
| tree | 28509d05c0fe9db08911c378834cb04cbc6849b3 /src | |
| parent | 1f3371b46e8a6a51f88c56785175b48af2a0bed7 (diff) | |
| download | emacs-ad004f10f3668d464d32ed8da18639da9bcc01bb.tar.gz emacs-ad004f10f3668d464d32ed8da18639da9bcc01bb.zip | |
* src/lisp.h (DOHASH): Handle rehashing (bug#68690)
I gave too much credit to the comment, and didn't realize that macro
was used in places that didn't obey the comment.
This macro is getting pretty hideous!
Diffstat (limited to 'src')
| -rw-r--r-- | src/lisp.h | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/src/lisp.h b/src/lisp.h index f822417ffb1..d07d9d14e2f 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -2604,20 +2604,30 @@ hash_from_key (struct Lisp_Hash_Table *h, Lisp_Object key) | |||
| 2604 | } | 2604 | } |
| 2605 | 2605 | ||
| 2606 | /* Iterate K and V as key and value of valid entries in hash table H. | 2606 | /* Iterate K and V as key and value of valid entries in hash table H. |
| 2607 | The body may remove the current entry or alter its value slot, but not | 2607 | The body may mutate the hash-table. */ |
| 2608 | mutate TABLE in any other way. */ | 2608 | #define DOHASH(h, k, v) \ |
| 2609 | #define DOHASH(h, k, v) \ | 2609 | for (Lisp_Object *dohash_##k##_##v##_base = (h)->key_and_value, \ |
| 2610 | for (Lisp_Object *dohash_##k##_##v##_kv = (h)->key_and_value, \ | 2610 | *dohash_##k##_##v##_kv = dohash_##k##_##v##_base, \ |
| 2611 | *dohash_##k##_##v##_end = dohash_##k##_##v##_kv \ | 2611 | *dohash_##k##_##v##_end = dohash_##k##_##v##_base \ |
| 2612 | + 2 * HASH_TABLE_SIZE (h), \ | 2612 | + 2 * HASH_TABLE_SIZE (h), \ |
| 2613 | k, v; \ | 2613 | k, v; \ |
| 2614 | dohash_##k##_##v##_kv < dohash_##k##_##v##_end \ | 2614 | dohash_##k##_##v##_kv < dohash_##k##_##v##_end \ |
| 2615 | && (k = dohash_##k##_##v##_kv[0], \ | 2615 | && (dohash_##k##_##v##_base == (h)->key_and_value \ |
| 2616 | v = dohash_##k##_##v##_kv[1], /*maybe unsed*/ (void)v, \ | 2616 | /* The `key_and_value` table has been reallocated! */ \ |
| 2617 | true); \ | 2617 | || (dohash_##k##_##v##_kv \ |
| 2618 | dohash_##k##_##v##_kv += 2) \ | 2618 | = (dohash_##k##_##v##_kv - dohash_##k##_##v##_base) \ |
| 2619 | if (hash_unused_entry_key_p (k)) \ | 2619 | + (h)->key_and_value, \ |
| 2620 | ; \ | 2620 | dohash_##k##_##v##_base = (h)->key_and_value, \ |
| 2621 | dohash_##k##_##v##_end = dohash_##k##_##v##_base \ | ||
| 2622 | + 2 * HASH_TABLE_SIZE (h), \ | ||
| 2623 | /* Check again, in case the table has shrunk. */ \ | ||
| 2624 | dohash_##k##_##v##_kv < dohash_##k##_##v##_end)) \ | ||
| 2625 | && (k = dohash_##k##_##v##_kv[0], \ | ||
| 2626 | v = dohash_##k##_##v##_kv[1], /*maybe unused*/ (void)v, \ | ||
| 2627 | true); \ | ||
| 2628 | dohash_##k##_##v##_kv += 2) \ | ||
| 2629 | if (hash_unused_entry_key_p (k)) \ | ||
| 2630 | ; \ | ||
| 2621 | else | 2631 | else |
| 2622 | 2632 | ||
| 2623 | 2633 | ||