From 5425edf173bf9efcf17955623e5be64196eae2fa Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 16 Jun 2017 16:23:22 +0000 Subject: Simplify the final loop when we know we're generating strings for all. --- generic/tclStringObj.c | 40 +++++++--------------------------------- 1 file changed, 7 insertions(+), 33 deletions(-) diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index be686cf..51d6c13 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -3007,48 +3007,22 @@ TclStringCatObjv( --oc; } - if (oc) { - - /* assert ( length > 0 ) */ - - - do { + while (oc) { int numBytes; - Tcl_Obj *objPtr = *ov++; - if ((length == 0) && (objPtr->bytes == NULL) && !pendingPtr) { - /* No string rep; Take the chance we can avoid making it */ + /* assert ( length > 0 && pendingPtr == NULL ) */ + Tcl_GetStringFromObj(objPtr, &numBytes); /* PANIC? */ + if (numBytes) { 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) { - 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) { + if (numBytes > INT_MAX - length) { goto overflow; } length += numBytes; } - } while (--oc); - } + --oc; + } } if (last <= first /*|| length == 0 */) { -- cgit v0.12