Tcl Source Code

Check-in [34daf5b5b3]
Login

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

Overview
Comment:Repaired the lost performance in the copy loop hotspots. Now meets or beats the former trunk (and current trunk by magnitudes) in tclbench.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | revert-3396731
Files: files | file ages | folders
SHA1: 34daf5b5b37cfe8bb11d71642c5e4b464d8e9ff1
User & Date: dgp 2011-08-27 02:28:47
Original Comment: Repaired the lost performance in the copy loop hotspots. Now meets or beats the former trunk (and current trunk by magnitudes) in tclbench.
Context
2011-08-27
04:24
3396731 Revise the [string reverse] implementation to operate on the representation that comes in, a... check-in: dc7f1a9b04 user: dgp tags: trunk
02:28
Repaired the lost performance in the copy loop hotspots. Now meets or beats the former trunk (and ... Closed-Leaf check-in: 34daf5b5b3 user: dgp tags: revert-3396731
2011-08-25
16:26
3396731 Another rewrite of TclStringObjReverse() to make it adopt the nijtmans approach for reversin... check-in: 61d345ff2f user: dgp tags: revert-3396731
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tclStringObj.c.

2656
2657
2658
2659
2660
2661
2662

2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685

2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
void
ReverseBytes(
    unsigned char *to,		/* Copy bytes into here... */
    unsigned char *from,	/* ...from here... */
    int count)		/* Until this many are copied, */
				/* reversing as you go. */
{

    if (to == from) {
	/* Reversing in place */
	from += count - 1;
	while (to < from) {
	    unsigned char c = *from;
	    *from-- = *to;
	    *to++ = c;
	}
    }  else {
	from += count - 1;
	while (count--) {
	    *to++ = *from--;
	}
    }
}

void
ReverseUniChars(
    Tcl_UniChar *to,		/* Copy Tcl_UniChars into here... */
    Tcl_UniChar *from,		/* ...from here... */
    unsigned int count)		/* Until this many are copied, */
				/* reversing as you go. */
{

    if (to == from) {
	/* Reversing in place */
	from += count - 1;
	while (to < from) {
	    Tcl_UniChar c = *from;
	    *from-- = *to;
	    *to++ = c;
	}
    }  else {
	from += count - 1;
	while (count--) {
	    *to++ = *from--;
	}
    }
}

Tcl_Obj *
TclStringObjReverse(
    Tcl_Obj *objPtr)







>


<
|
|
|



<
|
|











>



|
|
|



<
|
|







2656
2657
2658
2659
2660
2661
2662
2663
2664
2665

2666
2667
2668
2669
2670
2671

2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694

2695
2696
2697
2698
2699
2700
2701
2702
2703
void
ReverseBytes(
    unsigned char *to,		/* Copy bytes into here... */
    unsigned char *from,	/* ...from here... */
    int count)		/* Until this many are copied, */
				/* reversing as you go. */
{
    unsigned char *src = from + count - 1;
    if (to == from) {
	/* Reversing in place */

	while (to < src) {
	    unsigned char c = *src;
	    *src-- = *to;
	    *to++ = c;
	}
    }  else {

	while (src >= from) {
	    *to++ = *src--;
	}
    }
}

void
ReverseUniChars(
    Tcl_UniChar *to,		/* Copy Tcl_UniChars into here... */
    Tcl_UniChar *from,		/* ...from here... */
    unsigned int count)		/* Until this many are copied, */
				/* reversing as you go. */
{
    Tcl_UniChar *src = from + count - 1;
    if (to == from) {
	/* Reversing in place */
	from += count - 1;
	while (to < src) {
	    Tcl_UniChar c = *src;
	    *src-- = *to;
	    *to++ = c;
	}
    }  else {

	while (src >= from) {
	    *to++ = *src--;
	}
    }
}

Tcl_Obj *
TclStringObjReverse(
    Tcl_Obj *objPtr)