summaryrefslogtreecommitdiffstats
path: root/hash.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-05-27 20:47:15 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-05-27 20:47:15 -0700
commit5a4d281d6701e9f27b67bf9def3842780410ab56 (patch)
tree153269999a6bb764e8596befd47b8e5c4b9bf1ac /hash.h
parent3d9e60cb8ba2a9698336ae4697f59e14282a673d (diff)
downloadtxr-5a4d281d6701e9f27b67bf9def3842780410ab56.tar.gz
txr-5a4d281d6701e9f27b67bf9def3842780410ab56.tar.bz2
txr-5a4d281d6701e9f27b67bf9def3842780410ab56.zip
Reduce work done by hashing.
Curtail traversal of objects and strings. * hash.c (struct hash): hash_fun member takes int * parameter now. (HASH_STR_LIMIT, HASH_REC_LIMIT): New macros. (hash_c_str): Hash only HASH_STR_LIMIT characters. (equal_hash): Becomes extern function. Takes pointer-to-int count argument, which is decremented. Function stops recursing and returns zero when this hits zero. (eql_hash): Also takes int * param, for compatibility with function pointer in struct hash. This parameter is not used, though. (cobj_hash_op): Take pointer-to-count parameter, but ignore it. (hash_hash_op): Take pointer-to-count parameter, decrement and check that it has not hit zero, pass down to equal hash. (hash_grow, gethash_c, gethash, gethash_f, gethash_n, remhash): Initialize a counter to HASH_REC_LIMIT and pass down to hashing function. (hash_eql): Pass down a pointer to a dummy counter to eql_hash. (hash_equal): Initialize a counter to HASH_REC_LIMIT and pass down to hash_equal. * hash.h (equal_hash): Declared. * lib.h (cobj_ops): hash member takes int * parameter. (cobj_hash_op): Declaration updated with new param. * struct.c (struct_inst_hash): Takes new int * parameter for count. Calls equal_hash instead of hash_equal, eliminating c_num calls; pointer to count is passed to equal_hash.
Diffstat (limited to 'hash.h')
-rw-r--r--hash.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/hash.h b/hash.h
index a1ec19fc..29ff19d7 100644
--- a/hash.h
+++ b/hash.h
@@ -26,6 +26,7 @@
extern val weak_keys_k, weak_vals_k, equal_based_k;
+cnum equal_hash(val obj, int *count);
val make_hash(val weak_keys, val weak_vals, val equal_based);
val make_similar_hash(val existing);
val copy_hash(val existing);