summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorferrieux <ferrieux@noemail.net>2014-08-05 11:29:16 (GMT)
committerferrieux <ferrieux@noemail.net>2014-08-05 11:29:16 (GMT)
commit8cc60773c6816544ef078f3c745e2fb30d585abf (patch)
treef29ee3ef01f9e477a76c955a39309e9862198d9d
parentdc287d51a5c69c7d202eb2d8a4dceedb1ac752cf (diff)
downloadtcl-8cc60773c6816544ef078f3c745e2fb30d585abf.zip
tcl-8cc60773c6816544ef078f3c745e2fb30d585abf.tar.gz
tcl-8cc60773c6816544ef078f3c745e2fb30d585abf.tar.bz2
Better organize [string cat] by chunks of 255 args.
FossilOrigin-Name: 97af63ba9cfebc89e53d95a08baa89edaeafcf0d
-rw-r--r--generic/tclCompCmdsSZ.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/generic/tclCompCmdsSZ.c b/generic/tclCompCmdsSZ.c
index bd8b463..87b1ebb 100644
--- a/generic/tclCompCmdsSZ.c
+++ b/generic/tclCompCmdsSZ.c
@@ -277,7 +277,7 @@ TclCompileStringCatCmd(
* compiled. */
CompileEnv *envPtr) /* Holds resulting instructions. */
{
- int i,numWords = parsePtr->numWords;
+ int i, numWords = parsePtr->numWords, numArgs;
Tcl_Token *wordTokenPtr;
Tcl_Obj *obj, *folded;
DefineLineInformation; /* TIP #280 */
@@ -315,17 +315,19 @@ TclCompileStringCatCmd(
/* General case: just issue CONCAT1's (by chunks of 255 if needed) */
+ numArgs = 0;
wordTokenPtr = TokenAfter(parsePtr->tokenPtr);
for (i = 1; i < numWords; i++) {
CompileWord(envPtr, wordTokenPtr, interp, i);
+ numArgs ++;
+ if (numArgs == 255) {
+ TclEmitInstInt1(INST_STR_CONCAT1, 255, envPtr);
+ numArgs = 1; /* concat pushes 1 obj, the result */
+ }
wordTokenPtr = TokenAfter(wordTokenPtr);
}
- while (numWords > 256) {
- TclEmitInstInt1(INST_STR_CONCAT1, 255, envPtr);
- numWords -= 254; /* concat pushes 1 obj, the result */
- }
- if (numWords > 2) {
- TclEmitInstInt1(INST_STR_CONCAT1, numWords - 1, envPtr);
+ if (numArgs > 1) {
+ TclEmitInstInt1(INST_STR_CONCAT1, numArgs, envPtr);
}
return TCL_OK;