Tcl Source Code

Check-in [97af63ba9c]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Better organize [string cat] by chunks of 255 args.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tip-429
Files: files | file ages | folders
SHA1: 97af63ba9cfebc89e53d95a08baa89edaeafcf0d
User & Date: ferrieux 2014-08-05 11:29:16
Context
2014-08-05
18:20
More aggressive constant folding in [string cat]. Thanks AndreasK for kicking. check-in: 15f9b0abea user: ferrieux tags: tip-429
11:29
Better organize [string cat] by chunks of 255 args. check-in: 97af63ba9c user: ferrieux tags: tip-429
10:34
Add constant folding to [string cat]. Mixed-quote idiom is now compiled to a single push. check-in: a321e41d54 user: ferrieux tags: tip-429
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tclCompCmdsSZ.c.

273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
...
311
312
313
314
315
316
317

318
319
320
321
322
323

324
325
326


327
328
329
330
331
332
333
334
335
    Tcl_Interp *interp,		/* Used for error reporting. */
    Tcl_Parse *parsePtr,	/* Points to a parse structure for the command
				 * created by Tcl_ParseCommand. */
    Command *cmdPtr,		/* Points to defintion of command being
				 * compiled. */
    CompileEnv *envPtr)		/* Holds resulting instructions. */
{
    int i,numWords = parsePtr->numWords;
    Tcl_Token *wordTokenPtr;
    Tcl_Obj *obj, *folded;
    DefineLineInformation;	/* TIP #280 */

    /* Trivial case, no arg */

    if (numWords<2) {
................................................................................
	
	PushLiteral(envPtr, bytes, len);
	return TCL_OK;
    }

    /* General case: just issue CONCAT1's (by chunks of 255 if needed) */


    wordTokenPtr = TokenAfter(parsePtr->tokenPtr);
    for (i = 1; i < numWords; i++) {
	CompileWord(envPtr, wordTokenPtr, interp, i);
	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);
    }

    return TCL_OK;
}

int
TclCompileStringCmpCmd(






|







 







>



|
<
<
>
|
|
|
>
>
|
|







273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
...
311
312
313
314
315
316
317
318
319
320
321
322


323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
    Tcl_Interp *interp,		/* Used for error reporting. */
    Tcl_Parse *parsePtr,	/* Points to a parse structure for the command
				 * created by Tcl_ParseCommand. */
    Command *cmdPtr,		/* Points to defintion of command being
				 * compiled. */
    CompileEnv *envPtr)		/* Holds resulting instructions. */
{
    int i, numWords = parsePtr->numWords, numArgs;
    Tcl_Token *wordTokenPtr;
    Tcl_Obj *obj, *folded;
    DefineLineInformation;	/* TIP #280 */

    /* Trivial case, no arg */

    if (numWords<2) {
................................................................................
	
	PushLiteral(envPtr, bytes, len);
	return TCL_OK;
    }

    /* 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);
    }
    if (numArgs > 1) {
	TclEmitInstInt1(INST_STR_CONCAT1, numArgs, envPtr);
    }

    return TCL_OK;
}

int
TclCompileStringCmpCmd(