From 44fb1d2c660ae623debe25e06b4ce34c30791141 Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 16 Jun 2017 15:51:12 +0000 Subject: Factor out and simplify loop scanning leading known empty values. --- generic/tclStringObj.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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 */) { -- cgit v0.12