summaryrefslogtreecommitdiffstats
path: root/generic/tclHash.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclHash.c')
-rw-r--r--generic/tclHash.c40
1 files changed, 28 insertions, 12 deletions
diff --git a/generic/tclHash.c b/generic/tclHash.c
index f4b0a47..83bc0fb 100644
--- a/generic/tclHash.c
+++ b/generic/tclHash.c
@@ -318,22 +318,38 @@ CreateHashEntry(
if (typePtr->compareKeysProc) {
Tcl_CompareHashKeysProc *compareKeysProc = typePtr->compareKeysProc;
-
- for (hPtr = tablePtr->buckets[index]; hPtr != NULL;
- hPtr = hPtr->nextPtr) {
+ if (typePtr->flags & TCL_HASH_KEY_DIRECT_COMPARE) {
+ for (hPtr = tablePtr->buckets[index]; hPtr != NULL;
+ hPtr = hPtr->nextPtr) {
#if TCL_HASH_KEY_STORE_HASH
- if (hash != PTR2UINT(hPtr->hash)) {
- continue;
+ if (hash != PTR2UINT(hPtr->hash)) {
+ continue;
+ }
+#endif
+ /* if keys pointers or values are equal */
+ if ((key == hPtr->key.oneWordValue)
+ || compareKeysProc((void *) key, hPtr)
+ ) {
+ if (newPtr) {
+ *newPtr = 0;
+ }
+ return hPtr;
+ }
}
+ } else { /* no direct compare */
+ for (hPtr = tablePtr->buckets[index]; hPtr != NULL;
+ hPtr = hPtr->nextPtr) {
+#if TCL_HASH_KEY_STORE_HASH
+ if (hash != PTR2UINT(hPtr->hash)) {
+ continue;
+ }
#endif
- /* if keys pointers or values are equal */
- if ((key == hPtr->key.oneWordValue)
- || compareKeysProc((void *) key, hPtr)
- ) {
- if (newPtr) {
- *newPtr = 0;
+ if (compareKeysProc((void *) key, hPtr)) {
+ if (newPtr) {
+ *newPtr = 0;
+ }
+ return hPtr;
}
- return hPtr;
}
}
} else {