diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2018-05-07 15:42:08 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2018-05-07 15:42:08 (GMT) |
commit | 08f43a1ff49699c5bff357c9e7d56d2a06613179 (patch) | |
tree | 675f6aa966ed589eda136114e070460ac15b9d02 /generic/tclOOBasic.c | |
parent | 5cef8b0f8e5bcecd44d03df35952b0df592e6528 (diff) | |
download | tcl-08f43a1ff49699c5bff357c9e7d56d2a06613179.zip tcl-08f43a1ff49699c5bff357c9e7d56d2a06613179.tar.gz tcl-08f43a1ff49699c5bff357c9e7d56d2a06613179.tar.bz2 |
More efficient way of getting array element names; why search when direct lookup is possible?
Diffstat (limited to 'generic/tclOOBasic.c')
-rw-r--r-- | generic/tclOOBasic.c | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/generic/tclOOBasic.c b/generic/tclOOBasic.c index 7af25c0..6306416 100644 --- a/generic/tclOOBasic.c +++ b/generic/tclOOBasic.c @@ -783,26 +783,16 @@ TclOO_Object_VarName( varNamePtr = Tcl_NewObj(); if (aryVar != NULL) { - Tcl_HashEntry *hPtr; - Tcl_HashSearch search; - Tcl_GetVariableFullName(interp, (Tcl_Var) aryVar, varNamePtr); /* * WARNING! This code pokes inside the implementation of hash tables! */ - hPtr = Tcl_FirstHashEntry((Tcl_HashTable *) aryVar->value.tablePtr, - &search); - while (hPtr != NULL) { - if (varPtr == Tcl_GetHashValue(hPtr)) { - Tcl_AppendToObj(varNamePtr, "(", -1); - Tcl_AppendObjToObj(varNamePtr, hPtr->key.objPtr); - Tcl_AppendToObj(varNamePtr, ")", -1); - break; - } - hPtr = Tcl_NextHashEntry(&search); - } + Tcl_AppendToObj(varNamePtr, "(", -1); + Tcl_AppendObjToObj(varNamePtr, ((VarInHash *) + varPtr)->entry.key.objPtr); + Tcl_AppendToObj(varNamePtr, ")", -1); } else { Tcl_GetVariableFullName(interp, (Tcl_Var) varPtr, varNamePtr); } |