put back urem avoidance speedup rm'ed in last delta; other minor speedups
authorJay Lepreau <lepreau@ucbvax.Berkeley.EDU>
Tue, 13 Aug 1985 19:30:39 +0000 (11:30 -0800)
committerJay Lepreau <lepreau@ucbvax.Berkeley.EDU>
Tue, 13 Aug 1985 19:30:39 +0000 (11:30 -0800)
SCCS-vsn: usr.bin/diff/diff/diffreg.c 4.11

usr/src/usr.bin/diff/diff/diffreg.c

index 9be4f39..dd21a47 100644 (file)
@@ -1,4 +1,4 @@
-static char sccsid[] = "@(#)diffreg.c 4.10 %G%";
+static char sccsid[] = "@(#)diffreg.c 4.11 %G%";
 
 #include "diff.h"
 /*
 
 #include "diff.h"
 /*
@@ -448,7 +448,7 @@ check()
        register int i, j;
        int jackpot;
        long ctold, ctnew;
        register int i, j;
        int jackpot;
        long ctold, ctnew;
-       char c,d;
+       register int c,d;
 
        if ((input[0] = fopen(file1,"r")) == NULL) {
                perror(file1);
 
        if ((input[0] = fopen(file1,"r")) == NULL) {
                perror(file1);
@@ -590,8 +590,7 @@ int *b;
 
 skipline(f)
 {
 
 skipline(f)
 {
-       register i;
-       char c;
+       register i, c;
 
        for(i=1;(c=getc(input[f]))!='\n';i++)
                if (c < 0)
 
        for(i=1;(c=getc(input[f]))!='\n';i++)
                if (c < 0)
@@ -668,7 +667,7 @@ struct      context_vec     *context_vec_start,
 */
 change(a,b,c,d)
 {
 */
 change(a,b,c,d)
 {
-       char ch;
+       int ch;
        int lowa,upb,lowc,upd;
        struct stat stbuf;
 
        int lowa,upb,lowc,upd;
        struct stat stbuf;
 
@@ -824,6 +823,7 @@ char *s;
        }
 }
 
        }
 }
 
+#define POW2                   /* define only if HALFLONG is 2**n */
 #define HALFLONG 16
 #define low(x) (x&((1L<<HALFLONG)-1))
 #define high(x)        (x>>HALFLONG)
 #define HALFLONG 16
 #define low(x) (x&((1L<<HALFLONG)-1))
 #define high(x)        (x>>HALFLONG)
@@ -848,13 +848,23 @@ register FILE *f;
                        for(shift=0;(t=getc(f))!='\n';shift+=7) {
                                if(t==-1)
                                        return(0);
                        for(shift=0;(t=getc(f))!='\n';shift+=7) {
                                if(t==-1)
                                        return(0);
-                               sum += (long)chrtran[t] << (shift%=HALFLONG);
+                               sum += (long)chrtran[t] << (shift
+#ifdef POW2
+                                   &= HALFLONG - 1);
+#else
+                                   %= HALFLONG);
+#endif
                        }
                else
                        for(shift=0;(t=getc(f))!='\n';shift+=7) {
                                if(t==-1)
                                        return(0);
                        }
                else
                        for(shift=0;(t=getc(f))!='\n';shift+=7) {
                                if(t==-1)
                                        return(0);
-                               sum += (long)t << (shift%=HALFLONG);
+                               sum += (long)t << (shift
+#ifdef POW2
+                                   &= HALFLONG - 1);
+#else
+                                   %= HALFLONG);
+#endif
                        }
        } else {
                for(shift=0;;) {
                        }
        } else {
                for(shift=0;;) {
@@ -870,7 +880,12 @@ register FILE *f;
                                        shift += 7;
                                        space = 0;
                                }
                                        shift += 7;
                                        space = 0;
                                }
-                               sum += (long)chrtran[t] << (shift%=HALFLONG);
+                               sum += (long)chrtran[t] << (shift
+#ifdef POW2
+                                   &= HALFLONG - 1);
+#else
+                                   %= HALFLONG);
+#endif
                                shift += 7;
                                continue;
                        case '\n':
                                shift += 7;
                                continue;
                        case '\n':