diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2015-03-17 10:54:53 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2015-03-17 10:54:53 (GMT) |
commit | f132a440c7bba4bd7a71e2c7fad35cf92c5bb24b (patch) | |
tree | 08e16ab67487c7deb777e8615fe6041f298577f9 | |
parent | 5e056a674f16d91ada9d2056f6bd7e2d765ef735 (diff) | |
download | tcl-apn_hash_opt.zip tcl-apn_hash_opt.tar.gz tcl-apn_hash_opt.tar.bz2 |
Some cleanup of style issues.apn_hash_opt
-rw-r--r-- | generic/tclObj.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/generic/tclObj.c b/generic/tclObj.c index a8511bc..1eb7c0b 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -203,6 +203,14 @@ static Tcl_ThreadDataKey pendingObjDataKey; } /* + * How the hashcode is stored in a Tcl_Obj of type tclHashValueType. Note that + * this macro must give an L-value; it will be written through. + */ + +#define OBJHASH(objPtr) \ + ((objPtr)->internalRep.longValue) + +/* * Prototypes for functions defined later in this file: */ @@ -3975,10 +3983,12 @@ TclCompareObjKeys( * If the cached hash values are different, strings cannot be the same. * The converse obviously does not hold! */ - if (objPtr1->typePtr == &tclHashValueType && - objPtr2->typePtr == &tclHashValueType && - objPtr1->internalRep.longValue != objPtr2->internalRep.longValue) + + if (objPtr1->typePtr == &tclHashValueType + && objPtr2->typePtr == &tclHashValueType + && OBJHASH(objPtr1) != OBJHASH(objPtr2)) { return 0; + } /* * Don't use Tcl_GetStringFromObj as it would prevent l1 and l2 being @@ -4062,9 +4072,13 @@ TclHashObjKey( const char *string; unsigned int result = 0; - /* Return cached hash value if it exists */ - if (objPtr->typePtr == &tclHashValueType) - return objPtr->internalRep.longValue; + /* + * Return cached hash value if it exists. + */ + + if (objPtr->typePtr == &tclHashValueType) { + return OBJHASH(objPtr); + } string = TclGetStringFromObj(objPtr, &length); @@ -4110,12 +4124,13 @@ TclHashObjKey( } /* - * We do not want to shimmer other object types so only cache the - * hash if there is no associated type + * We do not want to shimmer other object types so only cache the hash if + * there is no associated type. */ + if (objPtr->typePtr == NULL) { objPtr->typePtr = &tclHashValueType; - objPtr->internalRep.longValue = result; + OBJHASH(objPtr) = result; } return result; |