diff options
author | dgp <dgp@users.sourceforge.net> | 2016-11-01 15:42:50 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2016-11-01 15:42:50 (GMT) |
commit | 17e1ea228c34a9c04121b8e9c4c0956896c72bb3 (patch) | |
tree | 52b0d7cb7390f6382be877a794f749ee0ad61a7b /generic/tclStringObj.c | |
parent | 53abdcc5182ac4f646357ba5f8a9d3a1a294af05 (diff) | |
download | tcl-17e1ea228c34a9c04121b8e9c4c0956896c72bb3.zip tcl-17e1ea228c34a9c04121b8e9c4c0956896c72bb3.tar.gz tcl-17e1ea228c34a9c04121b8e9c4c0956896c72bb3.tar.bz2 |
Replace indexing with pointer increments.
Diffstat (limited to 'generic/tclStringObj.c')
-rw-r--r-- | generic/tclStringObj.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index 05dcba4..7fd7cc1 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -2635,8 +2635,8 @@ TclStringCatObjv( Tcl_Obj * const objv[], Tcl_Obj **objPtrPtr) { - Tcl_Obj *objResultPtr; - int i, length = 0, binary = 1, first = 0; + Tcl_Obj *objPtr, *objResultPtr, * const *ov; + int oc, length = 0, binary = 1, first = 0; int allowUniChar = 1, requestUniChar = 0; /* assert (objc >= 2) */ @@ -2648,8 +2648,9 @@ TclStringCatObjv( * Error on overflow. */ - for (i = 0; i < objc && (binary || allowUniChar); i++) { - Tcl_Obj *objPtr = objv[i]; + ov = objv, oc = objc; + while (oc-- && (binary || allowUniChar)) { + objPtr = *ov++; if (objPtr->bytes) { /* Value has a string rep. */ @@ -2683,43 +2684,47 @@ TclStringCatObjv( if (binary) { /* Result will be pure byte array. Pre-size it */ - for (i = 0; i < objc && length >= 0; i++) { - Tcl_Obj *objPtr = objv[i]; + ov = objv; oc = objc; + while (oc-- && (length >= 0)) { + objPtr = *ov++; if (objPtr->bytes == NULL) { int numBytes; Tcl_GetByteArrayFromObj(objPtr, &numBytes); if (length == 0) { - first = i; + first = objc - oc - 1; } length += numBytes; } } } else if (allowUniChar && requestUniChar) { /* Result will be pure Tcl_UniChar array. Pre-size it. */ - for (i = 0; i < objc && length >= 0; i++) { - Tcl_Obj *objPtr = objv[i]; + ov = objv; oc = objc; + while (oc-- && (length >= 0)) { + objPtr = *ov++; if ((objPtr->bytes == NULL) || (objPtr->length)) { int numChars; Tcl_GetUnicodeFromObj(objPtr, &numChars); if (length == 0) { - first = i; + first = objc - oc - 1; } length += numChars; } } } else { /* Result will be concat of string reps. Pre-size it. */ - for (i = 0; i < objc && length >= 0; i++) { - Tcl_Obj *objPtr = objv[i]; + ov = objv; oc = objc; + while (oc-- && (length >= 0)) { int numBytes; + objPtr = *ov++; + Tcl_GetStringFromObj(objPtr, &numBytes); if ((length == 0) && numBytes) { - first = i; + first = objc - oc - 1; } length += numBytes; } |