Tcl Source Code

Check-in [6108355177]
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:Complete the "pure binary" implementation of the [string cat] engine.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dgp-string-cat
Files: files | file ages | folders
SHA1: 610835517710ef27c3458464706f442746840028
User & Date: dgp 2016-10-31 16:15:16
Context
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
14:18
merge trunk check-in: acd1d0f9c7 user: dgp tags: dgp-string-cat
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tclStringObj.c.

2690
2691
2692
2693
2694
2695
2696





2697


2698





2699
2700

2701
2702

2703
2704
2705
2706
2707
2708
2709
    objv += first; objc -= first;
    objResultPtr = *objv++; objc--;
    if (!inPlace || Tcl_IsShared(objResultPtr)) {
	objResultPtr = Tcl_DuplicateObj(objResultPtr);
    }

    if (binary) {





	Tcl_SetByteArrayLength(objResultPtr, length);


    }








    while (objc--) {
	Tcl_AppendObjToObj(objResultPtr, *objv++);

    }
    *objPtrPtr = objResultPtr;
    return TCL_OK;
}
 
/*
 *---------------------------------------------------------------------------






>
>
>
>
>
|
>
>
|
>
>
>
>
>
|
|
>
|
|
>







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
    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;
}
 
/*
 *---------------------------------------------------------------------------