Tcl Source Code

Check-in [210148adc5]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

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

Overview
Comment:Reduce copies in the pure binary implementation of [string cat].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dgp-string-cat
Files: files | file ages | folders
SHA1: 210148adc54428b923bd43af2d01b2a5e7f9ec1d
User & Date: dgp 2016-10-31 18:10:21
Context
2016-11-01
15:07
Expand all the cases of the [string cat] engine. check-in: 9bfada5e22 user: dgp tags: dgp-string-cat
2016-10-31
18:10
Reduce copies in the pure binary implementation of [string cat]. check-in: 210148adc5 user: dgp tags: dgp-string-cat
16:15
Complete the "pure binary" implementation of the [string cat] engine. check-in: 6108355177 user: dgp tags: dgp-string-cat
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tclStringObj.c.

2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698


2699
2700

2701
2702




2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713









2714
2715
2716
2717
2718
2719
2720
	    /* Total length of zero means every value has length zero */
	    *objPtrPtr = objv[0];
	    return TCL_OK;
	}
    } 

    objv += first; objc -= first;
    objResultPtr = *objv++; objc--;
    if (!inPlace || Tcl_IsShared(objResultPtr)) {
	objResultPtr = Tcl_DuplicateObj(objResultPtr);
    }

    if (binary) {
	/* Efficiently produce a pure binary result */
	unsigned char *dst;


	int start;


	Tcl_GetByteArrayFromObj(objResultPtr, &start);
	dst = Tcl_SetByteArrayLength(objResultPtr, length) + start;




	while (objc--) {
	    Tcl_Obj *objPtr = *objv++;

	    if (objPtr->bytes == NULL) {
		int more;
		unsigned char *src = Tcl_GetByteArrayFromObj(objPtr, &more);
		memcpy(dst, src, (size_t) more);
		dst += more;
	    }
	}
    } else {









	while (objc--) {
	    Tcl_AppendObjToObj(objResultPtr, *objv++);
	}
    }
    *objPtrPtr = objResultPtr;
    return TCL_OK;
}






<
<
<
<




>
>
|
|
>
|
|
>
>
>
>











>
>
>
>
>
>
>
>
>







2684
2685
2686
2687
2688
2689
2690




2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
	    /* Total length of zero means every value has length zero */
	    *objPtrPtr = objv[0];
	    return TCL_OK;
	}
    } 

    objv += first; objc -= first;





    if (binary) {
	/* Efficiently produce a pure binary result */
	unsigned char *dst;

	if (inPlace && !Tcl_IsShared(*objv)) {
	    int start;
	
	    objResultPtr = *objv++; objc--;
	    Tcl_GetByteArrayFromObj(objResultPtr, &start);
	    dst = Tcl_SetByteArrayLength(objResultPtr, length) + start;
	} else {
	    objResultPtr = Tcl_NewByteArrayObj(NULL, length);
	    dst = Tcl_SetByteArrayLength(objResultPtr, length);
	}
	while (objc--) {
	    Tcl_Obj *objPtr = *objv++;

	    if (objPtr->bytes == NULL) {
		int more;
		unsigned char *src = Tcl_GetByteArrayFromObj(objPtr, &more);
		memcpy(dst, src, (size_t) more);
		dst += more;
	    }
	}
    } else {


    objResultPtr = *objv++; objc--;
    if (!inPlace || Tcl_IsShared(objResultPtr)) {
	objResultPtr = Tcl_DuplicateObj(objResultPtr);
    }



	while (objc--) {
	    Tcl_AppendObjToObj(objResultPtr, *objv++);
	}
    }
    *objPtrPtr = objResultPtr;
    return TCL_OK;
}