[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/hash-table-perf f3e985a16ba 14/35: Don't print or read the hash
From: |
Mattias Engdegård |
Subject: |
scratch/hash-table-perf f3e985a16ba 14/35: Don't print or read the hash table size parameter |
Date: |
Thu, 4 Jan 2024 10:56:41 -0500 (EST) |
branch: scratch/hash-table-perf
commit f3e985a16ba52d6d12ba01ffa6cb3ca2b00dd240
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
Don't print or read the hash table size parameter
It's not a meaningful part of the external representation.
This allows for faster printing and reading, smaller
external representation, and less memory consumption.
* src/print.c (print_object): Omit size.
* src/lread.c (hash_table_from_plist): Take size from the data.
---
src/lread.c | 17 +++++++++--------
src/print.c | 7 ++-----
2 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/src/lread.c b/src/lread.c
index 255b6e914d9..a7ee0cb739c 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -3426,7 +3426,6 @@ hash_table_from_plist (Lisp_Object plist)
} \
} while (0)
- ADDPARAM (size);
ADDPARAM (test);
ADDPARAM (weakness);
ADDPARAM (rehash_size);
@@ -3434,23 +3433,25 @@ hash_table_from_plist (Lisp_Object plist)
ADDPARAM (purecopy);
Lisp_Object data = plist_get (plist, Qdata);
+ if (!(NILP (data) || CONSP (data)))
+ error ("Hash table data is not a list");
+ ptrdiff_t data_len = list_length (data);
+ if (data_len & 1)
+ error ("Hash table data length is odd");
+ *par++ = QCsize;
+ *par++ = make_fixnum (data_len / 2);
/* Now use params to make a new hash table and fill it. */
Lisp_Object ht = Fmake_hash_table (par - params, params);
- Lisp_Object last = data;
- FOR_EACH_TAIL_SAFE (data)
+ while (!NILP (data))
{
Lisp_Object key = XCAR (data);
data = XCDR (data);
- if (!CONSP (data))
- break;
Lisp_Object val = XCAR (data);
- last = XCDR (data);
Fputhash (key, val, ht);
+ data = XCDR (data);
}
- if (!NILP (last))
- error ("Hash table data is not a list of even length");
return ht;
}
diff --git a/src/print.c b/src/print.c
index 2da64c1d329..3c7e496bb51 100644
--- a/src/print.c
+++ b/src/print.c
@@ -2574,11 +2574,8 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun,
bool escapeflag)
{
struct Lisp_Hash_Table *h = XHASH_TABLE (obj);
/* Implement a readable output, e.g.:
- #s(hash-table size 2 test equal data (k1 v1 k2 v2)) */
- /* Always print the size. */
- int len = sprintf (buf, "#s(hash-table size %"pD"d",
- HASH_TABLE_SIZE (h));
- strout (buf, len, len, printcharfun);
+ #s(hash-table test equal data (k1 v1 k2 v2)) */
+ print_c_string ("#s(hash-table", printcharfun);
if (!BASE_EQ (h->test.name, Qeql))
{
- branch scratch/hash-table-perf created (now 681a2877cc2), Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf 594152bf667 01/35: Add internal hash-table debug functions, Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf 9f94796b657 05/35: ; * src/fns.c (collect_interval): Move misplaced function., Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf 31950946290 04/35: Refactor: less egregious layering violation in composite.h, Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf e2a6ce36d83 03/35: Decouple profiler from Lisp hash table internals, Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf 9141966be51 09/35: ; * src/alloc.c (purecopy_hash_table): Simplify, Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf fdc390f8dc0 10/35: Abstract predicate and constant for unused hash keys, Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf c4df6041de8 12/35: * src/print.c (print_object): Don't print hash table test if `eql`., Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf f3e985a16ba 14/35: Don't print or read the hash table size parameter,
Mattias Engdegård <=
- scratch/hash-table-perf 1ebd00f6d0a 21/35: Retype hash interfaces to use EMACS_UINT instead of Lisp fixnum, Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf fc68176120f 24/35: Use hash_hash_t for storing hash values, Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf 4b5d9f92abe 13/35: * src/print.c (print_object): Don't print empty hash-table data, Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf 310f6584ccb 18/35: Allow zero hash table size, Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf e53398ab698 26/35: ; Reorder structs (hash and test), Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf 4e8d7725fd4 11/35: ; * src/fns.c (Fmake_hash_table): ensure `test` is a bare symbol, Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf 8335891387a 22/35: Inlined and specialised hash table look-up, Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf 54807fee4d0 23/35: Use hash_idx_t for storing hash indices, Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf 8cd35079f4c 34/35: Don't pretend that hash-table-size is useful, Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf e6defe82569 27/35: Change default hash table size to 8 (from 65), Mattias Engdegård, 2024/01/04