summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordas <das>2004-11-11 01:18:07 (GMT)
committerdas <das>2004-11-11 01:18:07 (GMT)
commita0d4eac5974045d55b361a5e2ff674fffac3eb54 (patch)
treeb7ff7195c99b973bfa4111030d0ac0a9404feb6f /generic
parent855a4dd4649f658cd37ce56e3f87cce584fbde47 (diff)
downloadtcl-a0d4eac5974045d55b361a5e2ff674fffac3eb54.zip
tcl-a0d4eac5974045d55b361a5e2ff674fffac3eb54.tar.gz
tcl-a0d4eac5974045d55b361a5e2ff674fffac3eb54.tar.bz2
* generic/tclListObj.c (Tcl_ListObjReplace): use memmove() instead
of manual copy loop to shift list elements. Decreases time spent in Tcl_ListObjReplace() from 5.2% to 1.7% of overall runtime of tclbench on a ppc 7455 (i.e. 200% speed increase). [Patch 1064243] * generic/tclHash.c: hoisted some constant pointer dereferences out of loops to eliminate redundant loads that the gcc optimizer didn't deal with. Decreases time spend in Tcl_FindHashEntry() by 10% over a full run of the tcl testuite on a ppc 7455. [Patch 1064243]
Diffstat (limited to 'generic')
-rw-r--r--generic/tclHash.c13
-rw-r--r--generic/tclListObj.c16
2 files changed, 12 insertions, 17 deletions
diff --git a/generic/tclHash.c b/generic/tclHash.c
index 45726d9..ae2eca8 100644
--- a/generic/tclHash.c
+++ b/generic/tclHash.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclHash.c,v 1.12 2002/11/12 02:23:18 hobbs Exp $
+ * RCS: @(#) $Id: tclHash.c,v 1.12.2.1 2004/11/11 01:18:07 das Exp $
*/
#include "tclInt.h"
@@ -316,6 +316,7 @@ Tcl_FindHashEntry(tablePtr, key)
*/
if (typePtr->compareKeysProc) {
+ Tcl_CompareHashKeysProc *compareKeysProc = typePtr->compareKeysProc;
for (hPtr = tablePtr->buckets[index]; hPtr != NULL;
hPtr = hPtr->nextPtr) {
#if TCL_HASH_KEY_STORE_HASH
@@ -323,7 +324,7 @@ Tcl_FindHashEntry(tablePtr, key)
continue;
}
#endif
- if (typePtr->compareKeysProc ((VOID *) key, hPtr)) {
+ if (compareKeysProc ((VOID *) key, hPtr)) {
return hPtr;
}
}
@@ -414,6 +415,7 @@ Tcl_CreateHashEntry(tablePtr, key, newPtr)
*/
if (typePtr->compareKeysProc) {
+ Tcl_CompareHashKeysProc *compareKeysProc = typePtr->compareKeysProc;
for (hPtr = tablePtr->buckets[index]; hPtr != NULL;
hPtr = hPtr->nextPtr) {
#if TCL_HASH_KEY_STORE_HASH
@@ -421,7 +423,7 @@ Tcl_CreateHashEntry(tablePtr, key, newPtr)
continue;
}
#endif
- if (typePtr->compareKeysProc ((VOID *) key, hPtr)) {
+ if (compareKeysProc ((VOID *) key, hPtr)) {
*newPtr = 0;
return hPtr;
}
@@ -703,13 +705,14 @@ Tcl_NextHashEntry(searchPtr)
* Tcl_FirstHashEntry. */
{
Tcl_HashEntry *hPtr;
+ Tcl_HashTable *tablePtr = searchPtr->tablePtr;
while (searchPtr->nextEntryPtr == NULL) {
- if (searchPtr->nextIndex >= searchPtr->tablePtr->numBuckets) {
+ if (searchPtr->nextIndex >= tablePtr->numBuckets) {
return NULL;
}
searchPtr->nextEntryPtr =
- searchPtr->tablePtr->buckets[searchPtr->nextIndex];
+ tablePtr->buckets[searchPtr->nextIndex];
searchPtr->nextIndex++;
}
hPtr = searchPtr->nextEntryPtr;
diff --git a/generic/tclListObj.c b/generic/tclListObj.c
index cdd8cb9..446a67e 100644
--- a/generic/tclListObj.c
+++ b/generic/tclListObj.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclListObj.c,v 1.13 2002/01/07 23:09:13 dgp Exp $
+ * RCS: @(#) $Id: tclListObj.c,v 1.13.4.1 2004/11/11 01:18:07 das Exp $
*/
#include "tclInt.h"
@@ -680,17 +680,9 @@ Tcl_ListObjReplace(interp, listPtr, first, count, objc, objv)
if ((numAfterLast > 0) && (shift != 0)) {
Tcl_Obj **src, **dst;
- if (shift < 0) {
- for (src = elemPtrs + start, dst = src + shift;
- numAfterLast > 0; numAfterLast--, src++, dst++) {
- *dst = *src;
- }
- } else {
- for (src = elemPtrs + numElems - 1, dst = src + shift;
- numAfterLast > 0; numAfterLast--, src--, dst--) {
- *dst = *src;
- }
- }
+ src = elemPtrs + start; dst = src + shift;
+ memmove((VOID*) dst, (VOID*) src,
+ (size_t) (numAfterLast * sizeof(Tcl_Obj*)));
}
/*