Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion sources/declare.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,19 @@

/* (n) is necessary here, since the macro is sometimes passed dereferenced pointers for n */
#define NCOPY(s,t,n) { while ( (n)-- > 0 ) { *s++ = *t++; } }
/*#define NCOPY(s,t,n) { memcpy(s,t,n*sizeof(WORD)); s+=n; t+=n; n = -1; }*/
#define NCOPYI(s,t,n) { while ( (n)-- > 0 ) { *s++ = *t++; } }
#define NCOPYB(s,t,n) { while ( (n)-- > 0 ) { *s++ = *t++; } }
#define NCOPYI32(s,t,n) { while ( (n)-- > 0 ) { *s++ = *t++; } }
#define WCOPY(s,t,n) { int nn=n; WORD *ss=(WORD *)s, *tt=(WORD *)t; while ( (nn)-- > 0 ) { *ss++ = *tt++; } }

/* Use memmove not memcpy: we can't guarantee that s, t do not overlap */
/* Using memmove produces no measurable performance improvement or regression. */
/*#define NCOPY(s,t,n) { memmove(s,t,(n)*sizeof(*s)); s+=n; t+=n; n=0; }
#define NCOPYI(s,t,n) { NCOPY(s,t,n); }
#define NCOPYB(s,t,n) { NCOPY(s,t,n); }
#define NCOPYI32(s,t,n) { NCOPY(s,t,n); }
#define WCOPY(s,t,n) { int nn=n; WORD *ss=(WORD *)s, *tt=(WORD *)t; NCOPY(ss,tt,nn); }*/

#define NeedNumber(x,s,err) { int sgn = 1; \
while ( *s == ' ' || *s == '\t' || *s == '-' || *s == '+' ) { \
if ( *s == '-' ) {sgn = -sgn;} s++; } \
Expand Down
37 changes: 17 additions & 20 deletions sources/proces.c
Original file line number Diff line number Diff line change
Expand Up @@ -2220,11 +2220,10 @@ int InFunction(PHEAD WORD *term, WORD *termout)
AR.DeferFlag = 0;
v = t + *t;
t += ARGHEAD; /* First term */
w = 0; /* to appease the compilers warning devices */
while ( from < t ) {
if ( from == u ) w = m;
*m++ = *from++;
}
LONG copy = t - from;
const LONG size = t - u;
NCOPY(m, from, copy);
w = m - size;
to = m;
NewSort(BHEAD0);
if ( *u == AR.PolyFun && AR.PolyFunType == 2 ) {
Expand Down Expand Up @@ -2314,11 +2313,10 @@ int InFunction(PHEAD WORD *term, WORD *termout)
&& ( *u != AR.PolyFun ) ) { AN.ncmod = 0; }
AR.DeferFlag = 0;
v = t + 2;
w = 0; /* to appease the compilers warning devices */
while ( from < t ) {
if ( from == u ) w = m;
*m++ = *from++;
}
LONG copy = t - from;
const LONG size = t - u;
NCOPY(m, from, copy);
w = m - size;
to = m;
switch ( d->type ) {
case DOLINDEX:
Expand Down Expand Up @@ -2481,11 +2479,10 @@ int InFunction(PHEAD WORD *term, WORD *termout)
u points at the start of the function
t points at the start of the argument
*/
w = 0;
while ( from < t ) {
if ( from == u ) w = m;
*m++ = *from++;
}
LONG copy = t - from;
const LONG size = t - u;
NCOPY(m, from, copy);
w = m - size;
if ( ( numterms & MAXPOSITIVE ) == numterms ) {
*m++ = -SNUMBER; *m++ = numterms & MAXPOSITIVE;
w[1] += 1;
Expand Down Expand Up @@ -2548,11 +2545,11 @@ int InFunction(PHEAD WORD *term, WORD *termout)
if ( ( AN.ncmod != 0 )
&& ( ( AC.modmode & ALSOFUNARGS ) == 0 )
&& ( *u != AR.PolyFun ) ) { AN.ncmod = 0; }
m = termout; w = 0;
while ( from < t ) {
if ( from == u ) w = m;
*m++ = *from++;
}
m = termout;
LONG copy = t - from;
const LONG size = t - u;
NCOPY(m, from, copy);
w = m - size;
to = m;
switch ( d->type ) {
case DOLINDEX:
Expand Down
6 changes: 3 additions & 3 deletions sources/threads.c
Original file line number Diff line number Diff line change
Expand Up @@ -3543,9 +3543,9 @@ int PutToMaster(PHEAD WORD *term)
fill = AT.SB.MasterFill[i]; /* Where we are filling */
top = AT.SB.MasterStop[i]; /* End of the block */
while ( j > 0 ) {
while ( j > 0 && fill < top ) {
*fill++ = *t++; j--;
}
LONG copy = MiN(top - fill, j);
j -= copy;
NCOPY(fill, t, copy);
if ( j > 0 ) {
/*
We reached the end of the block.
Expand Down
Loading