diff options
author | dgp <dgp@users.sourceforge.net> | 2017-06-16 16:07:48 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2017-06-16 16:07:48 (GMT) |
commit | 58311abbb709a5255f685e5d45ae837b0e9c7251 (patch) | |
tree | 74a2664c9650c0760a0287f4bf49e79419a01e48 | |
parent | 44fb1d2c660ae623debe25e06b4ce34c30791141 (diff) | |
download | tcl-58311abbb709a5255f685e5d45ae837b0e9c7251.zip tcl-58311abbb709a5255f685e5d45ae837b0e9c7251.tar.gz tcl-58311abbb709a5255f685e5d45ae837b0e9c7251.tar.bz2 |
Split loop into two cases for further simplification.
-rw-r--r-- | generic/tclStringObj.c | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index 870696e..be686cf 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -2965,11 +2965,52 @@ TclStringCatObjv( } } while (--oc && (length == 0) && (pendingPtr == NULL)); + first = last = objc - oc - 1; + + while (oc && (length == 0)) { + int numBytes; + Tcl_Obj *objPtr = *ov++; + + /* assert ( pendingPtr != NULL ) <-- aiming for */ + + if ((length == 0) && (objPtr->bytes == NULL) && !pendingPtr) { + /* No string rep; Take the chance we can avoid making it */ + + last = objc - oc; + first = last; + pendingPtr = objPtr; + } else { + + Tcl_GetStringFromObj(objPtr, &numBytes); /* PANIC? */ + if (numBytes) { + last = objc - oc; + } else if (pendingPtr == NULL || pendingPtr->bytes == NULL) { + --oc; + continue; + } + if (pendingPtr) { + Tcl_GetStringFromObj(pendingPtr, &length); /* PANIC? */ + pendingPtr = NULL; + } + if (length == 0) { + if (numBytes) { + first = last; + } else { + first = objc - 1; + last = 0; + } + } else if (numBytes > INT_MAX - length) { + goto overflow; + } + length += numBytes; + } + --oc; + } + if (oc) { - /* assert ( length > 0 || pendingPtr != NULL ) */ + /* assert ( length > 0 ) */ - first = last = objc - oc - 1; do { int numBytes; |