Tcl Source Code

Check-in [025ea6e5be]
Login

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

Overview
Comment:Tweak string index boundary conditionals for tiny performance improvement and to make existing tests cover more code paths
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | amg-string-insert
Files: files | file ages | folders
SHA1: 025ea6e5be49d0773f457ddcfe8622bb389e7371
User & Date: andy 2017-08-20 19:55:28
Context
2017-08-20
19:57
Add tests to exercise almost every line of TclStringReplace(). The one line not being exercised is ... check-in: eb2821be09 user: andy tags: amg-string-insert
19:55
Tweak string index boundary conditionals for tiny performance improvement and to make existing tests... check-in: 025ea6e5be user: andy tags: amg-string-insert
18:13
Add non-bytecoded [string replace] tests to exercise new TclStringReplace() function check-in: 9af4defa79 user: andy tags: amg-string-insert
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tclStringObj.c.

3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
	insUni = Tcl_GetUnicodeFromObj(insObj, &insLen);
    }

    /*
     * Clip start index and removal count to lie within string length limits.
     */

    if (startIndex < 0) {
	idx = 0;
    } else if (startIndex > strLen) {
	idx = strLen;
    } else {
	idx = startIndex;
    }
    if (removeCount < 0) {
	del = 0;
    } else if (idx + removeCount > strLen) {
	del = strLen - idx;
    } else {
	del = removeCount;
    }

    /*
     * Setup is complete.  Now perform the actual string replacement.







|

|




|

|







3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
	insUni = Tcl_GetUnicodeFromObj(insObj, &insLen);
    }

    /*
     * Clip start index and removal count to lie within string length limits.
     */

    if (startIndex <= 0) {
	idx = 0;
    } else if (startIndex >= strLen) {
	idx = strLen;
    } else {
	idx = startIndex;
    }
    if (removeCount <= 0) {
	del = 0;
    } else if (idx + removeCount >= strLen) {
	del = strLen - idx;
    } else {
	del = removeCount;
    }

    /*
     * Setup is complete.  Now perform the actual string replacement.