diff options
| author | Mattias EngdegÄrd | 2024-01-19 15:17:52 +0100 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2024-01-21 11:21:51 +0100 |
| commit | fec87a4b36a67688932e7bb7e1720bd2c4363a61 (patch) | |
| tree | 8549ad5b17f75ba86a77e5fd8dea8a77bb3133af /src/fns.c | |
| parent | 0a07603ae8db41f69e83b1bfec6e28a92f737852 (diff) | |
| download | emacs-fec87a4b36a67688932e7bb7e1720bd2c4363a61.tar.gz emacs-fec87a4b36a67688932e7bb7e1720bd2c4363a61.zip | |
Add C macro for hash table iteration
This removes some boilerplate code and further reduces dependencies on
hash table implementation internals.
* src/lisp.h (DOHASH): New.
* src/comp.c (compile_function, Fcomp__compile_ctxt_to_file):
* src/composite.c (composition_gstring_cache_clear_font):
* src/emacs-module.c (module_global_reference_p):
* src/fns.c (Fmaphash):
* src/json.c (lisp_to_json_nonscalar_1):
* src/minibuf.c (Ftest_completion):
* src/print.c (print):
Use it instead of a hand-written loop.
Diffstat (limited to 'src/fns.c')
| -rw-r--r-- | src/fns.c | 9 |
1 files changed, 1 insertions, 8 deletions
| @@ -5655,14 +5655,7 @@ FUNCTION is called with two arguments, KEY and VALUE. | |||
| 5655 | (Lisp_Object function, Lisp_Object table) | 5655 | (Lisp_Object function, Lisp_Object table) |
| 5656 | { | 5656 | { |
| 5657 | struct Lisp_Hash_Table *h = check_hash_table (table); | 5657 | struct Lisp_Hash_Table *h = check_hash_table (table); |
| 5658 | 5658 | DOHASH (h, i) call2 (function, HASH_KEY (h, i), HASH_VALUE (h, i)); | |
| 5659 | for (ptrdiff_t i = 0; i < HASH_TABLE_SIZE (h); ++i) | ||
| 5660 | { | ||
| 5661 | Lisp_Object k = HASH_KEY (h, i); | ||
| 5662 | if (!hash_unused_entry_key_p (k)) | ||
| 5663 | call2 (function, k, HASH_VALUE (h, i)); | ||
| 5664 | } | ||
| 5665 | |||
| 5666 | return Qnil; | 5659 | return Qnil; |
| 5667 | } | 5660 | } |
| 5668 | 5661 | ||