summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2016-03-17 13:14:22 (GMT)
committerdgp <dgp@users.sourceforge.net>2016-03-17 13:14:22 (GMT)
commitbfa7cb3c5d224a86a6136bc063018638eb3b9a0b (patch)
treecdee27c48ce8b21a1806996d3ac4592e0f4d8a20 /generic
parent3126fa7b7c8fbc9d56eab9916693e0641cdd25de (diff)
downloadtcl-bfa7cb3c5d224a86a6136bc063018638eb3b9a0b.zip
tcl-bfa7cb3c5d224a86a6136bc063018638eb3b9a0b.tar.gz
tcl-bfa7cb3c5d224a86a6136bc063018638eb3b9a0b.tar.bz2
[ae38befcfb] Rewrite TclGetInnermostExceptionRange() for fewer iterations.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclCompile.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index 4c259ab..c0b5dcc 100644
--- a/generic/tclCompile.c
+++ b/generic/tclCompile.c
@@ -3360,26 +3360,25 @@ TclGetInnermostExceptionRange(
int returnCode,
ExceptionAux **auxPtrPtr)
{
- int exnIdx = -1, i;
+ int i = envPtr->exceptArrayNext;
+ ExceptionRange *rangePtr = envPtr->exceptArrayPtr + i;
- for (i=0 ; i<envPtr->exceptArrayNext ; i++) {
- ExceptionRange *rangePtr = &envPtr->exceptArrayPtr[i];
+ while (i > 0) {
+ rangePtr--; i--;
if (CurrentOffset(envPtr) >= rangePtr->codeOffset &&
(rangePtr->numCodeBytes == -1 || CurrentOffset(envPtr) <
rangePtr->codeOffset+rangePtr->numCodeBytes) &&
(returnCode != TCL_CONTINUE ||
envPtr->exceptAuxArrayPtr[i].supportsContinue)) {
- exnIdx = i;
+
+ if (auxPtrPtr) {
+ *auxPtrPtr = envPtr->exceptAuxArrayPtr + i;
+ }
+ return rangePtr;
}
}
- if (exnIdx == -1) {
- return NULL;
- }
- if (auxPtrPtr) {
- *auxPtrPtr = &envPtr->exceptAuxArrayPtr[exnIdx];
- }
- return &envPtr->exceptArrayPtr[exnIdx];
+ return NULL;
}
/*