diff options
author | dgp <dgp@users.sourceforge.net> | 2017-06-16 15:51:12 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2017-06-16 15:51:12 (GMT) |
commit | 44fb1d2c660ae623debe25e06b4ce34c30791141 (patch) | |
tree | 85cfe8d0369a0896cdcaa49e85b1869c77237017 | |
parent | 214ae82fc9c08209d8d3ed426f86a72b10410c4e (diff) | |
download | tcl-44fb1d2c660ae623debe25e06b4ce34c30791141.zip tcl-44fb1d2c660ae623debe25e06b4ce34c30791141.tar.gz tcl-44fb1d2c660ae623debe25e06b4ce34c30791141.tar.bz2 |
Factor out and simplify loop scanning leading known empty values.
-rw-r--r-- | generic/tclStringObj.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index 8155711..870696e 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -2952,6 +2952,26 @@ TclStringCatObjv( /* Result will be concat of string reps. Pre-size it. */ ov = objv; oc = objc; do { + /* assert ( pendingPtr == NULL ) */ + /* assert ( length == 0 ) */ + + Tcl_Obj *objPtr = *ov++; + + if (objPtr->bytes == NULL) { + /* No string rep; Take the chance we can avoid making it */ + pendingPtr = objPtr; + } else { + Tcl_GetStringFromObj(objPtr, &length); /* PANIC? */ + } + } while (--oc && (length == 0) && (pendingPtr == NULL)); + + if (oc) { + + /* assert ( length > 0 || pendingPtr != NULL ) */ + + first = last = objc - oc - 1; + + do { int numBytes; Tcl_Obj *objPtr = *ov++; @@ -2987,6 +3007,7 @@ TclStringCatObjv( length += numBytes; } } while (--oc); + } } if (last <= first /*|| length == 0 */) { |