summaryrefslogtreecommitdiff
path: root/src/fns.c
Commit message (Collapse)AuthorAge
* Fix value< string comparison ungoodthinkMattias Engdegård2024-04-29
| | | | | | * src/fns.c (string_cmp): Fix bad comparisons for certain strings. This only affected `value<` for aggregates, not `string<`. * test/src/fns-tests.el (fns-value<-ordered): Add test cases.
* (COMPILED): Rename to CLOSUREStefan Monnier2024-04-28
| | | | | | | | | | | | | | | | | | In preparation for the use of `PVEC_COMPILED` objects for interpreted functions, rename them to use a more neutral name. * src/lisp.h (enum pvec_type): Rename `PVEC_COMPILED` to `PVEC_CLOSURE`. (enum Lisp_Compiled): Use `CLOSURE_` prefix i.s.o `COMPILED_`. Also use `CODE` rather than `BYTECODE`. (CLOSUREP): Rename from `COMPILEDP`. (enum Lisp_Closure): Rename from `Lisp_Compiled`. * src/alloc.c, src/bytecode.c, src/comp.c, src/data.c, src/eval.c, * src/fns.c, src/lisp.h, src/lread.c, src/pdumper.c, src/print.c, * src/profiler.c: Rename all uses accordingly. * src/.gdbinit (xclosure): Rename from `xcompiled`. (xcompiled): New obsolete alias. (xpr): Adjust accordingly. Also adjust to new PVEC_CLOSURE tag name.
* * src/fns.c (Fvaluelt): More generous depth limit (20 -> 200).Mattias Engdegård2024-03-29
| | | | This gives `value<` the same limit as `equal` which seems about right.
* Faster non-destructive list sortingMattias Engdegård2024-03-29
| | | | | | | | Postpone the creation of a new list to after sorting which turns out to be a lot faster (1.1x - 1.5x speedup). * src/fns.c (sort_list, sort_vector, Fsort): Create the new list when moving the data out from the temporary array.
* Speed up `sort` by special-casing the `value<` orderingMattias Engdegård2024-03-29
| | | | | | | | | | | This gives a 1.5x-2x speed-up when using the default :lessp value, by eliminating the Ffuncall overhead. * src/sort.c (order_pred_lisp, order_pred_valuelt): New. (merge_state, inorder, binarysort, count_run, gallop_left, gallop_right) (merge_init, merge_lo, merge_hi, tim_sort): * src/fns.c (Fsort): When using value<, call it directly.
* New `sort` keyword arguments (bug#69709)Mattias Engdegård2024-03-29
| | | | | | | | | | | | | | Add the :key, :lessp, :reverse and :in-place keyword arguments. The old calling style remains available and is unchanged. * src/fns.c (sort_list, sort_vector, Fsort): * src/sort.c (tim_sort): Add keyword arguments with associated new features. All callers of Fsort adapted. * test/src/fns-tests.el (fns-tests--shuffle-vector, fns-tests-sort-kw): New test. * doc/lispref/sequences.texi (Sequence Functions): Update manual. * etc/NEWS: Announce.
* Add back timsort key function handling (bug#69709)Mattias Engdegård2024-03-29
| | | | | | | | | | | | | | | | | | | | | The original timsort code did provide for a key (accessor) function along with the necessary storage management, but we dropped it because our `sort` function didn't need it. Now it's been put back since it seems that it will come in handy after all. * src/fns.c (sort_list, sort_vector, Fsort): Pass Qnil as key function to tim_sort. * src/sort.c (reverse_slice, sortslice_copy) (sortslice_copy_incr, sortslice_copy_decr, sortslice_memcpy) (sortslice_memmove, sortslice_advance): New functions. (sortslice): New type. (struct stretch, struct reloc, merge_state) (binarysort, merge_init, merge_markmem, cleanup_mem) (merge_register_cleanup, merge_getmem, merge_lo, merge_hi, merge_at) (found_new_run, reverse_sortslice, resolve_fun, tim_sort): Merge back previously discarded parts from the upstreams timsort code that dealt with key functions, and adapt them to fit in.
* Add `value<` (bug#69709)Mattias Engdegård2024-03-29
| | | | | | | | | | | | | | | | | | | | | | It's a general-purpose polymorphic ordering function, like `<` but for any two values of the same type. * src/data.c (syms_of_data): Add the `type-mismatch` error. (bits_word_to_host_endian): Move... * src/lisp.h (bits_word_to_host_endian): ...here, and declare inline. * src/fns.c (Fstring_lessp): Extract the bulk of this function to... (string_cmp): ...this 3-way comparison function, for use elsewhere. (bool_vector_cmp, value_cmp, Fvaluelt): New. * lisp/emacs-lisp/byte-opt.el (side-effect-free-fns, pure-fns): Add `value<`, which is pure and side-effect-free. * test/src/fns-tests.el (fns-value<-ordered, fns-value<-unordered) (fns-value<-type-mismatch, fns-value<-symbol-with-pos) (fns-value<-circle, ert-deftest fns-value<-bool-vector): New tests. * doc/lispref/sequences.texi (Sequence Functions): * doc/lispref/numbers.texi (Comparison of Numbers): * doc/lispref/strings.texi (Text Comparison): Document the new value< function. * etc/NEWS: Announce.
* Add a proper type for obarraysMattias Engdegård2024-02-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new opaque type replaces the previous use of vectors for obarrays. `obarray-make` now returns objects of this type. Functions that take obarrays continue to accept vectors for compatibility, now just using their first slot to store an actual obarray object. obarray-size and obarray-default-size now obsolete. * lisp/obarray.el (obarray-default-size, obarray-size): Declare obsolete. (obarray-make, obarrayp, obarray-clear): Remove from here. * src/fns.c (reduce_emacs_uint_to_hash_hash): Remove from here. * src/lisp.h (struct Lisp_Obarray, OBARRAYP, XOBARRAY, CHECK_OBARRAY) (make_lisp_obarray, obarray_size, check_obarray) (obarray_iter_t, make_obarray_iter, obarray_iter_at_end) (obarray_iter_step, obarray_iter_symbol, DOOBARRAY, knuth_hash): New. (reduce_emacs_uint_to_hash_hash): Moved here. * src/lread.c (check_obarray): Renamed and reworked as... (checked_obarray_slow): ...this. (intern_sym, Funintern, oblookup, map_obarray) (Finternal__obarray_buckets): Adapt to new type. (obarray_index, allocate_obarray, make_obarray, grow_obarray) (obarray_default_bits, Fobarray_make, Fobarrayp, Fobarray_clear): New. * etc/emacs_lldb.py (Lisp_Object): * lisp/emacs-lisp/cl-macs.el (`(,type . ,pred)): * lisp/emacs-lisp/cl-preloaded.el (cl--typeof-types): * lisp/emacs-lisp/comp-common.el (comp-known-type-specifiers): * lisp/emacs-lisp/comp.el (comp-known-predicates): * src/alloc.c (cleanup_vector, process_mark_stack): * src/data.c (Ftype_of, syms_of_data): * src/minibuf.c (Ftry_completion, Fall_completions, Ftest_completion): * src/pdumper.c (dump_obarray_buckets, dump_obarray, dump_vectorlike): * src/print.c (print_vectorlike_unreadable): * test/lisp/abbrev-tests.el (abbrev-make-abbrev-table-test): * test/lisp/obarray-tests.el (obarrayp-test) (obarrayp-unchecked-content-test, obarray-make-default-test) (obarray-make-with-size-test): Adapt to new type.
* * src/fns.c (sxhash_bignum): Include sign bit in hash.Mattias Engdegård2024-02-23
|
* * src/fns.c (hash_string): Suppress warning on 32-bit platformsMattias Engdegård2024-02-23
| | | | | Remove a shift-too-wide complaint by GCC in code that is never reached on platforms where that shift is too wide.
* Replace XSET_HASH_TABLE with make_lisp_hash_tableMattias Engdegård2024-02-19
| | | | | * src/lisp.h (XSET_HASH_TABLE): Remove, replace with... (make_lisp_hash_table): ...this. All callers adapted.
* String hashing improvements (spread and performance)Mattias Engdegård2024-02-14
| | | | | | | | | | | | | | | | | | Fix gaps in hashing coverage in the middle and end of even fairly short strings. E.g., `outline-1`, `outline-2` etc all hashed to the exact same value but with the patch, there are no collisions among the ~160000 symbols in the Emacs tree. This change also improves average hashing speed by using fewer mixing operations. * src/fns.c (hash_string): Use unit stride for fairly short strings, while retaining the cap of 8 samples for long ones. Always hash the last word to ensure that the end of the string is covered. For strings shorter than a word, use fewer loads and a single reduction step.
* Remove SYMBOL_WITH_POS_{POS,SYM}Paul Eggert2024-02-13
| | | | | | | | | | | | | * src/fns.c (internal_equal): Turn comment into eassert that !symbols_with_pos_enabled. (sxhash_obj): Simplify case of symbol with pos (when enabled). * src/lisp.h (XSYMBOL_WITH_POS_SYM, XSYMBOL_WITH_POS_POS) (maybe_remove_pos_from_symbol): New inline functions. (SYMBOL_WITH_POS_SYM, SYMBOL_WITH_POS_POS): Remove. All uses replaced by the new functions. This avoids some double-checking in the source code, simplifies the code overall, and avoids the need for "Type checking is done in the following macro" comments to explain unusual code.
* Replace a few calls to intern with constant stringsPo Lu2024-02-09
| | | | | | | | | * src/fns.c (do_yes_or_no_p, Fyes_or_no_p): Use symbol globals rather than intern. (syms_of_fns) <Qyes_or_no_p, Qy_or_n_p>: New symbols. * src/lread.c (readevalloop): Use symbol global. (syms_of_lread) <Qinternal_macroexpand_for_load>: New symbol.
* Change hash range reduction from remainder to multiplicationMattias Engdegård2024-02-06
| | | | | | | | | | | | | | | | This makes both lookups and rehashing cheaper. The index vector size is now always a power of 2. The first table size is reduced to 6 (from 8), because index vectors would become excessively big otherwise. * src/lisp.h (struct Lisp_Hash_Table): Replace index_size with index_bits. All references adapted. (hash_table_index_size): New accessor; use it where applicable. * src/fns.c (hash_index_size): Replace with... (compute_hash_index_bits): ...this new function, returning the log2 of the index size. All callers adapted. (hash_index_index): Knuth multiplicative hashing instead of remainder. (maybe_resize_hash_table): Reduce first table size from 8 to 6.
* ; Fix typosStefan Kangas2024-02-04
|
* Allow equal user-defined hash table tests with different namesMattias Engdegård2024-01-31
| | | | | | | | | Hash tables using different user-defined tests defined identically sometimes ended up using the wrong test (bug#68668). * src/fns.c (get_hash_table_user_test): Take test name into account when matching the test object. * test/src/fns-tests.el (fns--define-hash-table-test): New.
* Add DOHASH_SAFE, make DOHASH faster (bug#68690)Mattias Engdegård2024-01-27
| | | | | | | | | | | | | | | Revert DOHASH to the fast (field-caching) implementation but with an assertion to detect misuses. Add DOHASH_SAFE for use in code that must tolerate arbitrary mutation of the table being iterated through. * src/lisp.h (DOHASH): Go back to fast design that only allows restricted mutation, but with a checking assertion. (DOHASH_SAFE): New macro that tolerates arbitrary mutation while being much simpler (and acceptably fast). * src/fns.c (Fmaphash): * src/comp.c (compile_function, Fcomp__compile_ctxt_to_file): Use DOHASH_SAFE.
* (DOHASH): Change calling conventionStefan Monnier2024-01-24
| | | | | | | | | | | | | | | | | This leads to simpler code in the users, and more efficient machine code because we don't repeatedly need to fetch the `table_size` and `key_and_value` fields of the hash table object. * src/lisp.h (DOHASH): Rewrite. * src/composite.c (composition_gstring_lookup_cache): Simplify. (composition_gstring_cache_clear_font): * src/print.c (print): * src/pdumper.c (hash_table_contents): * src/minibuf.c (Ftest_completion): * src/json.c (lisp_to_json_nonscalar_1): * src/emacs-module.c (module_global_reference_p): * src/comp.c (compile_function, Fcomp__compile_ctxt_to_file): * src/fns.c (Fmaphash): Adjust to new calling convention.
* Make better use of fixnum range in sxhash etcMattias Engdegård2024-01-21
| | | | | | | | | | | | Recent hash table changes reduced the range of sxhash, sxhash-eq etc to [0,2**32) on platforms with 62-bit fixnums. This change makes them use the full fixnum range again. Hash table hashing is unaffected. * src/fns.c (sxhash_eq, sxhash_eql): New. (hash_hash_to_fixnum): Replace with... (reduce_emacs_uint_to_fixnum): ...this. (hashfn_eq, hashfn_eql, Fsxhash_eq, Fsxhash_eql, Fsxhash_equal) (Fsxhash_equal_including_properties): Use the new functions.
* Clarify permitted mutation in `maphash` documentationMattias Engdegård2024-01-21
| | | | | | | * doc/lispref/hash.texi (Hash Access): * src/fns.c (Fmaphash): Make it clear what the function passed as argument can do. Until now these rules were unwritten, and are still unenforced.
* Add C macro for hash table iterationMattias Engdegård2024-01-21
| | | | | | | | | | | | | | | 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.
* Only use a hash index size of 1 for tables with size 0 (bug#68244)Mattias Engdegård2024-01-18
| | | | | | | | This invariant was intended but insufficiently enforced which could lead to an assertion failure. * src/fns.c (hash_index_size): Assume size>0, and return a value >1. (make_hash_table): Only use hash_index_size for size>0.
* More efficient hash table thawingMattias Engdegård2024-01-16
| | | | | | * src/fns.c (hash_table_thaw): Don't allocate anything for empty tables. Don't initialise the next vector twice. (maybe_resize_hash_table): Factor out min_size constant.
* Make object-intervals linear instead of quadraticMattias Engdegård2024-01-14
| | | | | | * src/fns.c (collect_interval, Fobject_intervals): Build the returned list in reverse instead of appending single elements.
* Speed up sxhash-equal-including-propertiesMattias Engdegård2024-01-14
| | | | | | | | | | This function now no longer conses at all. Previously, it constructed a list structure of all string intervals for the sole purpose of hashing. * src/fns.c (hash_interval): New. (Fsxhash_equal_including_properties): Use it instead of collect_interval.
* Retype traverse_interval arg type from Lisp_Object to void *Mattias Engdegård2024-01-14
| | | | | | | | | | | | | This is a refactoring. It eliminates a few unnecessary conses and allows for further improvements. * src/intervals.c (traverse_intervals): Change argument type. All callers adapted. * src/fns.c (collect_interval, Fsxhash_equal_including_properties) (Fobject_intervals): * src/print.c (print_check_string_charset_prop) (print_prune_string_charset, print_object, print_interval): Pass a pointer to a Lisp_Object instead of a Lisp_Object.
* Hash-table documentation updates (bug#68244)Mattias Engdegård2024-01-13
| | | | | | | | | | * doc/lispref/hash.texi (Creating Hash, Other Hash): Manual updates for make-hash-table, hash-table-rehash-size and hash-table-rehash-threshold. * doc/lispref/objects.texi (Hash Table Type): Update example. * src/fns.c (Fhash_table_rehash_size, Fhash_table_rehash_threshold): Update doc strings. * etc/NEWS: Announce changes.
* Don't pretend that hash-table-size is usefulMattias Engdegård2024-01-13
| | | | | | | * lisp/emacs-lisp/shortdoc.el (hash-table): Remove hash-table-size entry. * doc/lispref/hash.texi (Other Hash): * src/fns.c (Fhash_table_size): Make it clear that hash-table-size is probably not worth using.
* Change hash_hash_t to uint32_tMattias Engdegård2024-01-13
| | | | | | | | | | | | | | | | | | | | | This saves a lot of memory and is quite sufficient. Hash functions are adapted to produce a hash_hash_t eventually, which eliminates some useless and information-destroying intermediate hash reduction steps. We still use EMACS_UINT for most of the actual hashing steps before producing the final value; this may be slightly wasteful on 32-bit platforms with 64-bit EMACS_UINT. * src/lisp.h (hash_hash_t): Change to uint32_t. * src/fns.c (reduce_emacs_uint_to_hash_hash): New. (hashfn_eq, hashfn_equal, hashfn_user_defined): Reduce return values to hash_hash_t. (sxhash_string): Remove. Caller changed to hash_string. (sxhash_float, sxhash_list, sxhash_vector, sxhash_bool_vector) (sxhash_bignum): Remove wasteful calls to SXHASH_REDUCE. (hash_hash_to_fixnum): New. (Fsxhash_eq, Fsxhash_eql, Fsxhash_equal) (Fsxhash_equal_including_properties): Convert return values to fixnum.
* Use key Qunbound instead of hash value hash_unused for free entriesMattias Engdegård2024-01-13
| | | | | | | | | | | | Previously, free hash table entries were indicated by both hash value hash_unused and key Qunbound; we now rely on the latter only. This allows us to change the hash representation to one that does not have an unused value. * src/lisp.h (hash_unused): Remove. All uses adapted to calling hash_unused_entry_key_p on the key instead. The hash values for unused hash table entries are now undefined; all initialisation and assignment to hash_unused has been removed.
* Don't dump QunboundMattias Engdegård2024-01-13
| | | | | | | | | | | | | | The dumper uses a hash table to keep track of dumped objects but as this clashes with the use of Qunbound for marking unused hash table entries, don't dump that value at all. The symbol name is fixed up after loading. An alternative solution would be to use a different unique value for unused entries. * src/pdumper.c (dump_object_needs_dumping_p): Skip Qunbound. (dump_vectorlike_generic): New function. (pdumper_load): Call it.
* Change hash_idx_t to int32_t on all platformsMattias Engdegård2024-01-13
| | | | | * src/lisp.h (hash_idx_t): Change to int32_t. * src/fns.c (hash_index_size): Adapt to new index type.
* Faster hash table growth, starting at zero sizeMattias Engdegård2024-01-13
| | | | | | | | | | | | | | | | | | | The algorithms no longer use the rehash_threshold and rehash_size float constants, but vary depending on size. In particular, the table now grows faster, especially from smaller sizes. The default size is now 0, starting empty, which effectively postpones allocation until the first insertion (unless make-hash-table was called with a positive :size); this is a clear gain as long as the table remains empty. The first inserted item will use an initial size of 8 because most tables are small. * src/fns.c (std_rehash_size, std_rehash_threshold): Remove. (hash_index_size): Integer-only computation. (maybe_resize_hash_table): Grow more aggressively. (Fhash_table_rehash_size, Fhash_table_rehash_threshold): Use the constants directly. * src/lisp.h (DEFAULT_HASH_SIZE): New value.
* ; Reorder struct Lisp_Hash_Table and struct hash_table_testMattias Engdegård2024-01-13
| | | | Mainly for efficiency, to keep frequently used fields together.
* Share hash table test structsMattias Engdegård2024-01-13
| | | | | | | | | | | | | | | | This saves several words in the hash table object at the cost of an indirection at runtime. This seems to be a gain in overall performance. FIXME: We cache hash test objects in a rather clumsy way. A better solution is sought. * src/lisp.h (struct Lisp_Hash_Table): Use a pointer to the test struct. All references adapted. * src/alloc.c (garbage_collect): * src/fns.c (struct hash_table_user_test, hash_table_user_tests) (mark_fns, get_hash_table_user_test): New state for caching test structs, and functions managing it.
* Use hash_idx_t for storing hash indicesMattias Engdegård2024-01-13
| | | | | | | | | | | Now hash_idx_t is a typedef for ptrdiff_t so there is no actual code change, but this allows us to decouple the index width from the Lisp word size. * src/lisp.h (hash_idx_t): New typedef for ptrdiff_t. (struct Lisp_Hash_Table): Use it for indices and sizes: index, next, table_size, index_size, count and next_free. All uses adapted.
* Inlined and specialised hash table look-upMattias Engdegård2024-01-13
| | | | | | | | | | | This improves performance in several ways. Separate functions are used depending on whether the caller has a hash value computed or not. * src/fns.c (hash_lookup_with_hash, hash_lookup_get_hash): New. (hash_lookup): Remove hash return argument. All callers adapted. hash_lookup_with_hash hash_hash_t arg
* Store hash values as integers instead of Lisp_ObjectMattias Engdegård2024-01-13
| | | | | | | | | | | | | | | | | | | This improves typing, saves pointless tagging and untagging, and prepares for further changes. The new typedef hash_hash_t is an alias for EMACS_UINT, and hash values are still limited to the fixnum range. We now use hash_unused instead of Qnil to mark unused entries. * src/lisp.h (hash_hash_t): New typedef for EMACS_UINT. (hash_unused): New constant. (struct hash_table_test): `hashfn` now returns hash_hash_t. All callers and implementations changed. (struct Lisp_Hash_Table): Retype hash vector to an array of hash_hash_t. All code using it changed accordingly. (HASH_HASH, hash_from_key): * src/fns.c (set_hash_index_slot, hash_index_index) (hash_lookup_with_hash, hash_lookup_get_hash, hash_put): (hash_lookup, hash_put): Retype hash value arguments and return values. All callers adapted.
* Use non-Lisp allocation for internal hash-table vectorsMattias Engdegård2024-01-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using xmalloc for allocating these arrays is much cheaper than using Lisp vectors since they are no longer marked or swept by the GC, and deallocated much sooner. This makes GC faster and less frequent, and improves temporal locality. Zero-sized tables use NULL for their (0-length) vectors except the index vector which has size 1 and uses a shared constant static vector since it cannot be modified anyway. This makes creation and destruction of zero-sized hash tables very fast; they consume no memory outside the base object. * src/lisp.h (struct Lisp_Hash_Table): Retype the index, next, hash and key_and_value vectors from Lisp_Object to appropriately typed arrays (although hash values are still stored as Lisp fixnums). Add explicit table_size and index_size members. All users updated. * src/alloc.c (gcstat): Add total_hash_table_bytes. (hash_table_allocated_bytes): New. (cleanup_vector): Free hash table vectors when sweeping the object. (hash_table_alloc_bytes, hash_table_free_bytes): New. (sweep_vectors): Update gcstat.total_hash_table_bytes. (total_bytes_of_live_objects): Use it. (purecopy_hash_table): Adapt allocation of hash table vectors. (process_mark_stack): No more Lisp slots in the struct to trace. * src/fns.c (empty_hash_index_vector): New. (allocate_hash_table): Allocate without automatically GCed slots. (alloc_larger_vector): Remove. (make_hash_table, copy_hash_table, maybe_resize_hash_table): Adapt vector allocation and initialisation. * src/pdumper.c (hash_table_freeze, hash_table_thaw, dump_hash_table) (dump_hash_table_contents): Adapt dumping and loading to field changes.
* Allow zero hash table sizeMattias Engdegård2024-01-13
| | | | | | | | | | | This avoids any extra allocation for such vectors, including empty tables read by the Lisp reader, and provides extra safety essentially for free. * src/fns.c (make_hash_table): Allow tables to be 0-sized. The index will always have at least one entry, to avoid extra look-up costs. * src/alloc.c (process_mark_stack): Don't mark pure objects, because empty vectors are pure.
* Leaner hash table dumping and thawingMattias Engdegård2024-01-13
| | | | | | | | | | | | | | | | | | | Only dump the actual data, and the test encoded as an enum. This simplifies dumping, makes dump files smaller and saves space at run time. * src/lisp.h (hash_table_std_test_t): New enum. (struct Lisp_Hash_Table): Add frozen_test member, consuming no extra space. * src/fns.c (hashfn_user_defined): Now static. (hash_table_test_from_std): New. (hash_table_rehash): Rename to... (hash_table_thaw): ...this and rewrite. * src/pdumper.c (hash_table_contents): Only include actual data, not unused space. (hash_table_std_test): New. (hash_table_freeze): Set frozen_test from test. (dump_hash_table): Dump frozen_test, not the whole test struct. Don't bother other dumping fields that can be derived.
* Remove rehash-threshold and rehash-size struct membersMattias Engdegård2024-01-13
| | | | | | | | | | | | | | | | | | | | | | | | | These parameters have no visible semantics and are hardly ever used, so just use the default values for all hash tables. This saves memory, shrinks the external representation, and will improve performance. * src/fns.c (std_rehash_size, std_rehash_threshold): New. (hash_index_size): Use std_rehash_threshold. Remove table argument. All callers updated. (make_hash_table): Remove rehash_size and rehash_threshold args. All callers updated. (maybe_resize_hash_table) (Fhash_table_rehash_size, Fhash_table_rehash_threshold): Use std_rehash_size and std_rehash_threshold. (Fmake_hash_table): Ignore :rehash-size and :rehash-threshold args. * src/lisp.h (struct Lisp_Hash_Table): Remove rehash_size and rehash_threshold fields. (DEFAULT_REHASH_THRESHOLD, DEFAULT_REHASH_SIZE): Remove. * src/lread.c (hash_table_from_plist): Don't read rehash-size or rehash-threshold. (syms_of_lread): Remove unused symbols. * src/print.c (print_object): Don't print rehash-size or rehash-threshold. * src/pdumper.c (dump_hash_table): Don't dump removed fields.
* Represent hash table weakness as an enum internallyMattias Engdegård2024-01-13
| | | | | | | | | | | | | | | | 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.
* * src/fns.c (maybe_resize_hash_table): Fix EMACS_INT format specifier.Eli Zaretskii2024-01-13
|
* ; * src/fns.c (Fmake_hash_table): ensure `test` is a bare symbolMattias Engdegård2024-01-12
|
* Abstract predicate and constant for unused hash keysMattias Engdegård2024-01-12
| | | | | | | | | | | | | | | | | | Qunbound is used for many things; using a predicate and constant for the specific purpose of unused hash entry keys allows us to locate them and make changes much more easily. * src/lisp.h (HASH_UNUSED_ENTRY_KEY, hash_unused_entry_key_p): New constant and function. * 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 (make_hash_table, maybe_resize_hash_table, hash_put) (hash_remove_from_table, hash_clear, sweep_weak_table, Fmaphash): * src/json.c (lisp_to_json_nonscalar_1): * src/minibuf.c (Ftry_completion, Fall_completions, Ftest_completion): * src/print.c (print, print_object): Use them.
* Refactor hash table vector reallocationMattias Engdegård2024-01-12
| | | | | | | | * src/fns.c (larger_vecalloc): Remove. (larger_vector): Simplify. (alloc_larger_vector): New. (maybe_resize_hash_table): Use alloc_larger_vector as a simpler and faster replacement for larger_vecalloc.
* Refactor: extract hash and index computations to functionsMattias Engdegård2024-01-12
| | | | | | | | * src/lisp.h (hash_from_key): * src/fns.c (hash_index_index): New. (hash_table_rehash, hash_lookup, hash_remove_from_table): (maybe_resize_hash_table, hash_put): * src/composite.c (composition_gstring_put_cache): Use them.