diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-05-13 15:23:08 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-05-13 15:23:08 (GMT) |
commit | 683756c1bdcc1745f0953b26f798154e1fdff5a1 (patch) | |
tree | 09b6a976eb8712446f41b0438c85a03a25cd7f3a /generic | |
parent | 137310bc48c268ffa2c880ec847258e394e1475c (diff) | |
download | tcl-683756c1bdcc1745f0953b26f798154e1fdff5a1.zip tcl-683756c1bdcc1745f0953b26f798154e1fdff5a1.tar.gz tcl-683756c1bdcc1745f0953b26f798154e1fdff5a1.tar.bz2 |
In some places, Tcl_UtfPrev()/Tcl_UtfNext() is used traversing the individual bytes of a string searching for '(', ')', '::' or other single bytes. It is overkill to use Tcl_UtfPrev/Tcl_UtfNext for that, since those characters can only appear as their ASCII byte, not as any other sequence.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclCompCmds.c | 11 | ||||
-rw-r--r-- | generic/tclProc.c | 4 |
2 files changed, 7 insertions, 8 deletions
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c index d8f0aeb..fa192ef 100644 --- a/generic/tclCompCmds.c +++ b/generic/tclCompCmds.c @@ -3441,10 +3441,10 @@ TclPushVarName( /* * last char is ')' => potential array reference. */ - last = Tcl_UtfPrev(name + nameLen, name); + last = &name[nameLen-1]; if (*last == ')') { - for (p = name; p < last; p = Tcl_UtfNext(p)) { + for (p = name; p < last; p++) { if (*p == '(') { elName = p + 1; elNameLen = last - elName; @@ -3472,15 +3472,14 @@ TclPushVarName( } else if (interp && ((n = varTokenPtr->numComponents) > 1) && (varTokenPtr[1].type == TCL_TOKEN_TEXT) && (varTokenPtr[n].type == TCL_TOKEN_TEXT) - && (*((p = varTokenPtr[n].start + varTokenPtr[n].size)-1) == ')') - && (*Tcl_UtfPrev(p, varTokenPtr[n].start) == ')')) { + && (*(varTokenPtr[n].start + varTokenPtr[n].size - 1) == ')')) { /* * Check for parentheses inside first token. */ simpleVarName = 0; for (p = varTokenPtr[1].start, - last = p + varTokenPtr[1].size; p < last; p = Tcl_UtfNext(p)) { + last = p + varTokenPtr[1].size; p < last; p++) { if (*p == '(') { simpleVarName = 1; break; @@ -3548,7 +3547,7 @@ TclPushVarName( int hasNsQualifiers = 0; - for (p = name, last = p + nameLen-1; p < last; p = Tcl_UtfNext(p)) { + for (p = name, last = p + nameLen-1; p < last; p++) { if ((*p == ':') && (*(p+1) == ':')) { hasNsQualifiers = 1; break; diff --git a/generic/tclProc.c b/generic/tclProc.c index f050d54..7be1fb7 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -511,7 +511,7 @@ TclCreateProc( */ argnamei = argname; - argnamelast = Tcl_UtfPrev(argname + nameLength, argname); + argnamelast = (nameLength > 0) ? (argname + nameLength - 1) : argname; while (argnamei < argnamelast) { if (*argnamei == '(') { if (*argnamelast == ')') { /* We have an array element. */ @@ -532,7 +532,7 @@ TclCreateProc( "FORMALARGUMENTFORMAT", NULL); goto procError; } - argnamei = Tcl_UtfNext(argnamei); + argnamei++; } if (precompiled) { |