Tcl Source Code

Check-in [afd6a2812b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Split loop into two cases for further simplification.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: afd6a2812b62c1a7e8597daa11f9ffb317c118fe
User & Date: dgp 2017-06-16 16:07:48
Context
2017-06-16
16:23
Simplify the final loop when we know we're generating strings for all. check-in: 20cca1d020 user: dgp tags: trunk
16:07
Split loop into two cases for further simplification. check-in: afd6a2812b user: dgp tags: trunk
15:51
Factor out and simplify loop scanning leading known empty values. check-in: 1e6a22b0fc user: dgp tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tclStringObj.c.

2960
2961
2962
2963
2964
2965
2966
2967










































2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
	    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++;

	    if ((length == 0) && (objPtr->bytes == NULL) && !pendingPtr) {








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


|

<







2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013

3014
3015
3016
3017
3018
3019
3020
	    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));

	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 )  */



	do {
	    int numBytes;

	    Tcl_Obj *objPtr = *ov++;

	    if ((length == 0) && (objPtr->bytes == NULL) && !pendingPtr) {