diff options
author | ferrieux <ferrieux@users.sourceforge.net> | 2014-08-05 11:29:16 (GMT) |
---|---|---|
committer | ferrieux <ferrieux@users.sourceforge.net> | 2014-08-05 11:29:16 (GMT) |
commit | 201e2d1d6adb55742fd72f75a35c18bba901a0eb (patch) | |
tree | 9c0e83f9367344ad9d0857b022583d47720a74f0 | |
parent | 60a802acb616e77ccf3cab5328dccaea820f3e66 (diff) | |
download | tcl-201e2d1d6adb55742fd72f75a35c18bba901a0eb.zip tcl-201e2d1d6adb55742fd72f75a35c18bba901a0eb.tar.gz tcl-201e2d1d6adb55742fd72f75a35c18bba901a0eb.tar.bz2 |
Better organize [string cat] by chunks of 255 args.
-rw-r--r-- | generic/tclCompCmdsSZ.c | 16 |
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; |