diff options
| author | Mattias EngdegÄrd | 2023-10-26 15:49:32 +0200 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2024-01-13 20:50:37 +0100 |
| commit | c6bdc1ea1dc7f9a0b6d92d443f34c42affde73d1 (patch) | |
| tree | d913aa29399325b0e1ab08fce48bbaae6eb3068c /src/alloc.c | |
| parent | 3f9c81a87f7bce854489b8232d817b536ccf349b (diff) | |
| download | emacs-c6bdc1ea1dc7f9a0b6d92d443f34c42affde73d1.tar.gz emacs-c6bdc1ea1dc7f9a0b6d92d443f34c42affde73d1.zip | |
Represent hash table weakness as an enum internally
This takes less space (saves an entire word) and is more type-safe.
No change in behaviour.
* src/lisp.h (hash_table_weakness_t): New.
(struct Lisp_Hash_Table): Replace Lisp object `weak` with enum
`weakness`.
* src/fns.c
(keep_entry_p, hash_table_weakness_symbol): New.
(make_hash_table): Retype argument. All callers updated.
(sweep_weak_table, Fmake_hash_table, Fhash_table_weakness):
* src/alloc.c (purecopy_hash_table, purecopy, process_mark_stack):
* src/pdumper.c (dump_hash_table):
* src/print.c (print_object): Use retyped field.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/alloc.c b/src/alloc.c index af9c169a3a0..17ed711a318 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -5887,7 +5887,7 @@ make_pure_vector (ptrdiff_t len) | |||
| 5887 | static struct Lisp_Hash_Table * | 5887 | static struct Lisp_Hash_Table * |
| 5888 | purecopy_hash_table (struct Lisp_Hash_Table *table) | 5888 | purecopy_hash_table (struct Lisp_Hash_Table *table) |
| 5889 | { | 5889 | { |
| 5890 | eassert (NILP (table->weak)); | 5890 | eassert (table->weakness == Weak_None); |
| 5891 | eassert (table->purecopy); | 5891 | eassert (table->purecopy); |
| 5892 | 5892 | ||
| 5893 | struct Lisp_Hash_Table *pure = pure_alloc (sizeof *pure, Lisp_Vectorlike); | 5893 | struct Lisp_Hash_Table *pure = pure_alloc (sizeof *pure, Lisp_Vectorlike); |
| @@ -5960,7 +5960,7 @@ purecopy (Lisp_Object obj) | |||
| 5960 | /* Do not purify hash tables which haven't been defined with | 5960 | /* Do not purify hash tables which haven't been defined with |
| 5961 | :purecopy as non-nil or are weak - they aren't guaranteed to | 5961 | :purecopy as non-nil or are weak - they aren't guaranteed to |
| 5962 | not change. */ | 5962 | not change. */ |
| 5963 | if (!NILP (table->weak) || !table->purecopy) | 5963 | if (table->weakness != Weak_None || !table->purecopy) |
| 5964 | { | 5964 | { |
| 5965 | /* Instead, add the hash table to the list of pinned objects, | 5965 | /* Instead, add the hash table to the list of pinned objects, |
| 5966 | so that it will be marked during GC. */ | 5966 | so that it will be marked during GC. */ |
| @@ -7233,7 +7233,7 @@ process_mark_stack (ptrdiff_t base_sp) | |||
| 7233 | mark_stack_push_value (h->test.name); | 7233 | mark_stack_push_value (h->test.name); |
| 7234 | mark_stack_push_value (h->test.user_hash_function); | 7234 | mark_stack_push_value (h->test.user_hash_function); |
| 7235 | mark_stack_push_value (h->test.user_cmp_function); | 7235 | mark_stack_push_value (h->test.user_cmp_function); |
| 7236 | if (NILP (h->weak)) | 7236 | if (h->weakness == Weak_None) |
| 7237 | mark_stack_push_value (h->key_and_value); | 7237 | mark_stack_push_value (h->key_and_value); |
| 7238 | else | 7238 | else |
| 7239 | { | 7239 | { |