Skip to content

Commit 8941fac

Browse files
committed
perf: improve copies in PutBracket, DoIfStatement, Generator, PrepPoly
1 parent 25d1630 commit 8941fac

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

sources/execute.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1601,7 +1601,9 @@ NextSymbol2:;
16011601
if ( AR.BracketOn < 0 ) {
16021602
s1 = t1; t1 = t2; t2 = s1;
16031603
}
1604-
do { *t2++ = *t++; } while ( t < (WORD *)tStopa );
1604+
/* Old code copied 1 element if copy == 0. This doesn't happen in the test suite. */
1605+
LONG copy = tStopa - t;
1606+
NCOPY(t2, t, copy);
16051607
t = AT.WorkPointer;
16061608
i = WORDDIF(t1,term1);
16071609
*t++ = 4 + i + WORDDIF(t2,term2);

sources/if.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ donemul: if ( i ) { ncoef2 = 1; coef2 = Spac2; coef2[0] = coef2[1] = 1; }
816816
}
817817
coef1 = Spac1;
818818
i = 2*ABS(ncoef2);
819-
for ( j = 0; j < i; j++ ) coef1[j] = coef2[j];
819+
WCOPY(coef1, coef2, i);
820820
ncoef1 = ncoef2;
821821
SkipCond:
822822
ifp += ifp[1];

sources/proces.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3414,10 +3414,10 @@ SkipCount: level++;
34143414
are involved in a match(). Hence we have to make
34153415
a private copy here!!!!
34163416
*/
3417-
WORD ic, jc, *ifcode, *jfcode;
3417+
WORD jc, *ifcode, *jfcode;
34183418
jfcode = C->lhs[level]; jc = jfcode[1];
34193419
ifcode = AT.WorkPointer; AT.WorkPointer += jc;
3420-
for ( ic = 0; ic < jc; ic++ ) ifcode[ic] = jfcode[ic];
3420+
WCOPY(ifcode, jfcode, jc);
34213421
while ( !DoIfStatement(BHEAD ifcode,term) ) {
34223422
level = C->lhs[level][2];
34233423
if ( C->lhs[level][0] != TYPEELIF ) break;

sources/sort.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4624,9 +4624,7 @@ int StoreTerm(PHEAD WORD *term)
46244624
while ( ( t = *ss++ ) != 0 ) {
46254625
j = *t;
46264626
if ( j < 0 ) j = t[1] + 2;
4627-
while ( --j >= 0 ){
4628-
*lfill++ = *t++;
4629-
}
4627+
NCOPY(lfill, t, j);
46304628
}
46314629
}
46324630
*lfill++ = 0;
@@ -4636,7 +4634,7 @@ int StoreTerm(PHEAD WORD *term)
46364634
*(S->PoinFill) = S->sFill = S->sBuffer;
46374635
}
46384636
j = *term;
4639-
while ( --j >= 0 ) *S->sFill++ = *term++;
4637+
NCOPY(S->sFill, term, j);
46404638
S->sTerms++;
46414639
S->GenTerms++;
46424640
S->TermsLeft++;

0 commit comments

Comments
 (0)