[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/hash-table-perf 08acca67739 14/35: Don't print or read the hash
From: |
Mattias Engdegård |
Subject: |
scratch/hash-table-perf 08acca67739 14/35: Don't print or read the hash table size parameter |
Date: |
Fri, 12 Jan 2024 10:53:24 -0500 (EST) |
branch: scratch/hash-table-perf
commit 08acca67739e19222cc55576e94b0a83dd8818a0
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 8ec0e030b66), Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf a39bca66533 03/35: Decouple profiler from Lisp hash table internals, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf dd89a9fb76d 04/35: Refactor: less layering violation in composite.h, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf 05694f4491d 08/35: ; * src/alloc.c (purecopy_hash_table): Simplify, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf b9b2c5a12a8 10/35: ; * src/fns.c (Fmake_hash_table): ensure `test` is a bare symbol, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf b96f48232ac 11/35: ; * src/lisp.h (struct Lisp_Hash_Table): Add ASCII art., Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf d7dbbc74a00 13/35: * src/print.c (print_object): Don't print empty hash-table data, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf 9b39cee78e3 12/35: * src/print.c (print_object): Don't print hash table test if `eql`., Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf 08acca67739 14/35: Don't print or read the hash table size parameter,
Mattias Engdegård <=
- scratch/hash-table-perf b1218be258a 18/35: Allow zero hash table size, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf 8f608cb4a1c 28/35: Use key Qunbound instead of hash value hash_unused for free entries, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf 93d6326e6c0 32/35: Hash-table documentation updates, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf 1462fca6dce 16/35: Remove rehash-threshold and rehash-size struct members, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf 3b3fea97ecc 22/35: Use hash_idx_t for storing hash indices, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf 58559a83827 29/35: * src/lisp.h (hash_hash_t): Change to uint32_t., Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf 441c4d53cf6 31/35: Don't pretend that hash-table-size is useful, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf a0560e90d3b 26/35: Change hash_idx_t to int32_t on all platforms, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf 8ec0e030b66 35/35: Combine hash and next vector into a single array, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf b9a0b88aea8 05/35: ; * src/fns.c (collect_interval): Move misplaced function., Mattias Engdegård, 2024/01/12