[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master a09619f2598 02/20: * src/print.c (print_object): Don't print empt
From: |
Mattias Engdegård |
Subject: |
master a09619f2598 02/20: * src/print.c (print_object): Don't print empty hash-table data |
Date: |
Sat, 13 Jan 2024 14:53:59 -0500 (EST) |
branch: master
commit a09619f2598a1658feac6794e85bc61a07c4855f
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
* src/print.c (print_object): Don't print empty hash-table data
Since no data is the default, this preserves bidirectional compatibility.
---
src/print.c | 37 +++++++++++++++++++++++--------------
test/src/print-tests.el | 7 -------
2 files changed, 23 insertions(+), 21 deletions(-)
diff --git a/src/print.c b/src/print.c
index 0a5f2ee48d4..d011962d85b 100644
--- a/src/print.c
+++ b/src/print.c
@@ -2603,21 +2603,30 @@ print_object (Lisp_Object obj, Lisp_Object
printcharfun, bool escapeflag)
if (h->purecopy)
print_c_string (" purecopy t", printcharfun);
- print_c_string (" data (", printcharfun);
-
ptrdiff_t size = h->count;
- /* Don't print more elements than the specified maximum. */
- if (FIXNATP (Vprint_length) && XFIXNAT (Vprint_length) < size)
- size = XFIXNAT (Vprint_length);
-
- print_stack_push ((struct print_stack_entry){
- .type = PE_hash,
- .u.hash.obj = obj,
- .u.hash.nobjs = size * 2,
- .u.hash.idx = 0,
- .u.hash.printed = 0,
- .u.hash.truncated = (size < h->count),
- });
+ if (size > 0)
+ {
+ print_c_string (" data (", printcharfun);
+
+ /* Don't print more elements than the specified maximum. */
+ if (FIXNATP (Vprint_length) && XFIXNAT (Vprint_length) < size)
+ size = XFIXNAT (Vprint_length);
+
+ print_stack_push ((struct print_stack_entry){
+ .type = PE_hash,
+ .u.hash.obj = obj,
+ .u.hash.nobjs = size * 2,
+ .u.hash.idx = 0,
+ .u.hash.printed = 0,
+ .u.hash.truncated = (size < h->count),
+ });
+ }
+ else
+ {
+ /* Empty table: we can omit the data entirely. */
+ printchar (')', printcharfun);
+ --print_depth; /* Done with this. */
+ }
goto next_obj;
}
diff --git a/test/src/print-tests.el b/test/src/print-tests.el
index aedaa9a4e06..ff3a6fe7483 100644
--- a/test/src/print-tests.el
+++ b/test/src/print-tests.el
@@ -367,13 +367,6 @@ otherwise, use a different charset."
(remhash 1 h)
(format "%S" h))))
- (should
- (string-match
- "data ()"
- (let ((h (make-hash-table)))
- (let ((print-length 0))
- (format "%S" h)))))
-
(should
(string-match
"data (99 99)"
- master updated (76904626b36 -> d2c3a983146), Mattias Engdegård, 2024/01/13
- master 4ba6954e695 01/20: * src/print.c (print_object): Don't print hash table test if `eql`., Mattias Engdegård, 2024/01/13
- master 49fd4d120de 07/20: Allow zero hash table size, Mattias Engdegård, 2024/01/13
- master c3d0cc50faf 05/20: Remove rehash-threshold and rehash-size struct members, Mattias Engdegård, 2024/01/13
- master a3ae5653cfe 09/20: Store hash values as integers instead of Lisp_Object, Mattias Engdegård, 2024/01/13
- master ed06de52a53 14/20: Faster hash table growth, starting at zero size, Mattias Engdegård, 2024/01/13
- master fa5c07fc87d 08/20: Use non-Lisp allocation for internal hash-table vectors, Mattias Engdegård, 2024/01/13
- master 7ad5d427730 16/20: Don't dump Qunbound, Mattias Engdegård, 2024/01/13
- master d2c3a983146 20/20: Hash-table documentation updates (bug#68244), Mattias Engdegård, 2024/01/13
- master a09619f2598 02/20: * src/print.c (print_object): Don't print empty hash-table data,
Mattias Engdegård <=
- master 3f9c81a87f7 03/20: Don't print or read the hash table size parameter, Mattias Engdegård, 2024/01/13
- master d3cefd3e983 06/20: Leaner hash table dumping and thawing, Mattias Engdegård, 2024/01/13
- master 519c7ca7356 19/20: Don't pretend that hash-table-size is useful, Mattias Engdegård, 2024/01/13
- master 3b00255a4c7 10/20: Inlined and specialised hash table look-up, Mattias Engdegård, 2024/01/13
- master 1998039f7a8 18/20: Change hash_hash_t to uint32_t, Mattias Engdegård, 2024/01/13
- master 7d93a0147a1 12/20: Share hash table test structs, Mattias Engdegård, 2024/01/13
- master 47502c55b0c 13/20: ; Reorder struct Lisp_Hash_Table and struct hash_table_test, Mattias Engdegård, 2024/01/13
- master c6bdc1ea1dc 04/20: Represent hash table weakness as an enum internally, Mattias Engdegård, 2024/01/13
- master 68f8bc31114 15/20: Change hash_idx_t to int32_t on all platforms, Mattias Engdegård, 2024/01/13
- master 0a998938ca1 11/20: Use hash_idx_t for storing hash indices, Mattias Engdegård, 2024/01/13