diff options
author | dgp <dgp@users.sourceforge.net> | 2016-03-17 13:14:22 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2016-03-17 13:14:22 (GMT) |
commit | abdb62c1942d36d9a145b5c1cfb572839b1a9a25 (patch) | |
tree | cdee27c48ce8b21a1806996d3ac4592e0f4d8a20 /generic/tclCompile.c | |
parent | 63a966a40e845f10d76af23a49673eddaeb7a7e6 (diff) | |
download | tcl-abdb62c1942d36d9a145b5c1cfb572839b1a9a25.zip tcl-abdb62c1942d36d9a145b5c1cfb572839b1a9a25.tar.gz tcl-abdb62c1942d36d9a145b5c1cfb572839b1a9a25.tar.bz2 |
[ae38befcfb] Rewrite TclGetInnermostExceptionRange() for fewer iterations.
Diffstat (limited to 'generic/tclCompile.c')
-rw-r--r-- | generic/tclCompile.c | 21 |
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; } /* |