Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site umcp-cs.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.unix-wizards Subject: Re: Possible TROFF speedup Message-ID: <1407@umcp-cs.UUCP> Date: Tue, 27-Aug-85 07:47:18 EDT Article-I.D.: umcp-cs.1407 Posted: Tue Aug 27 07:47:18 1985 Date-Received: Wed, 28-Aug-85 10:36:06 EDT References: <658@wdl1.UUCP> <2707@sun.uucp> Organization: U of Maryland, Computer Science Dept., College Park, MD Lines: 705 I had a set of n/troff changes for 4.1BSD that gave a ~10% improvement, as I recall. Let me see if I can find them.... Ah, here we go. Please note that these are for 4.1BSD; I haven't reinstalled them in 4.2 myself (perhaps someone else has), and we don't run System N. First, add the following at the end of tdef.h: ------------------------------------------------------------------- /* NOTE: THIS WON'T WORK UNDER NON-VMUNIX!! */ /* Troff spends about 20% of its time in getch() and getch0(); this is an attempt to speed that up. */ #ifdef FAST int _ch_, ch, nlflg, ch0, nchar, rchar, app; int *rbuf, Buf[NBLIST*BLK + NEV*EVS], *olinep; filep roff; #define getch() (ch?((((_ch_=ch)&CMASK)=='\n'?nlflg++:0),ch=0,_ch_):\ nlflg?'\n':_getch_()) #define getch0() (ch0?(_ch_=ch0,ch0=0,_ch_):nchar?(--nchar,rchar):_getch0_()) #define rbf0(p) (((p)&~(BLK-1))==roff?rbuf[(p)&(BLK-1)]:\ (roff=(p)&(~(BLK-1)),rbuf= &Buf[roff],rbuf[p&(BLK-1)])) #define rbf() (((_ch_=rbf0(ip))==0?(app?0:(_ch_=popi()))\ :(ip=incoff(ip))),_ch_) #define wbt(i) (wbf(i),wbfl()) #ifdef NROFF int oline[LNSIZE+1]; #define ptout(i) ((olinep>= &oline[LNSIZE]?0:(*olinep++=(i))),\ ((i)&CMASK)=='\n'?_ptout_(i):0) #else (TROFF) #define ptout(i) (((i)&CMASK)!='\n'?*olinep++=(i):_ptout_()) #endif NROFF #endif FAST ------------------------------------------------------------------- Now, the RCS diffs for the other files. There are some other changes in here; you can try using just the code that is conditional on FAST, if you wish. RCS file: RCS/n1.c,v retrieving revision 1.1 retrieving revision 1.2 diff -c2 -r1.1 -r1.2 *** /tmp/,RCSt1001198 Tue Aug 27 07:37:26 1985 --- /tmp/,RCSt2001198 Tue Aug 27 07:37:28 1985 *************** *** 142,145 int acctf; #endif main(argc,argv) --- 142,146 ----- int acctf; #endif + char *getenv(); main(argc,argv) *************** *** 250,253 dpn = 0; continue; #endif default: --- 251,260 ----- dpn = 0; continue; + case 'F': + { + extern char *fontfile; + fontfile = &argv[0][2]; + } + continue; #endif default: *************** *** 418,421 { static int mode; if (ttyp==0) --- 425,430 ----- { static int mode; + char *tbptr; + char tbuf[1024]; /* 11-3-83 EMA & BNI *************** *** 419,422 static int mode; if (ttyp==0) return; --- 428,440 ----- char tbuf[1024]; + /* 11-3-83 EMA & BNI + Added following check so that messages are only turned off + if the output is going to the terminal, and the terminal + is a hard copy terminal or of unknown type */ + + tbptr = getenv ("TERM"); + if (! isatty(2) || (tgetent (tbuf,tbptr) > 0) && ! tgetflag("hc")) + return; + if (ttyp==0) return; *************** *** 449,453 { register i,j; ! extern filep boff(); i = a; --- 467,471 ----- { register i,j; ! /* extern filep boff(); */ i = a; *************** *** 473,477 return(i); } ! getch(){ register int i, j, k; --- 491,497 ----- return(i); } ! ! #ifndef FAST ! getch () { register int i, j, k; *************** *** 477,480 level++; g0: if(ch){ --- 497,509 ----- level++; + #else FAST + _getch_ () { + register int i, j, k; + + level++; + /* when we get here we know ch and nlflag are both zero */ + goto gfast; + #endif FAST + g0: if(ch){ *************** *** 490,493 } if((k = (i = getch0()) & CMASK) != ESC){ if(i & MOT)goto g2; --- 519,523 ----- } + gfast: if((k = (i = getch0()) & CMASK) != ESC){ if(i & MOT)goto g2; *************** *** 702,706 } char ifilt[32] = {0,001,002,003,0,005,006,007,010,011,012}; ! getch0(){ register int i, j; --- 732,738 ----- } char ifilt[32] = {0,001,002,003,0,005,006,007,010,011,012}; ! ! #ifndef FAST ! getch0 () { register int i, j; *************** *** 707,710 if(ch0){i=ch0; ch0=0; return(i);} if(nchar){nchar--; return(rchar);} again: --- 739,746 ----- if(ch0){i=ch0; ch0=0; return(i);} if(nchar){nchar--; return(rchar);} + #else FAST + _getch0_ () { + register int i, j; + #endif FAST again: =================================================================== RCS file: RCS/n3.c,v retrieving revision 1.1 retrieving revision 1.2 diff -c2 -r1.1 -r1.2 *** /tmp/,RCSt1001198 Tue Aug 27 07:37:36 1985 --- /tmp/,RCSt2001198 Tue Aug 27 07:37:37 1985 *************** *** 16,19 */ unsigned blist[NBLIST]; extern struct s *frame, *stk, *nxf; --- 16,22 ----- */ + #define blisti(i) (((i)-NEV*EVS)/(BLK)) + #define boff(i) (((filep)i)*BLK + NEV*EVS) + unsigned blist[NBLIST]; extern struct s *frame, *stk, *nxf; *************** *** 134,138 } findmn(i) ! int i; { register j; --- 137,141 ----- } findmn(i) ! register i; { register j; *************** *** 137,140 { register j; for(j=0;jrq & ~MMASK)) ! break; ! j = p - contab; ! if (j == NM) ! j = -1; return(j); } *************** *** 147,151 int i; { - extern filep boff(); if(i >= 0){ if(contab[i].rq & MMASK)ffree(((filep)contab[i].x.mx)<= 0){ if(contab[i].rq & MMASK)ffree(((filep)contab[i].x.mx)<3)){prstr("fp: bad font position\n"); return;} if(skip() || !(j = getrq())){prstr("fp: no font name\n"); return;} fontfile[ffi] = j & BMASK; fontfile[ffi+1] = j>>BYTE; --- 506,512 ----- if(((i = (getch() & CMASK) - '0' -1) < 0) || (i >3)){prstr("fp: bad font position\n"); return;} if(skip() || !(j = getrq())){prstr("fp: no font name\n"); return;} + if (ffi == 0) + while (fontfile[ffi] != 'X') + ffi++; fontfile[ffi] = j & BMASK; fontfile[ffi+1] = j>>BYTE; =================================================================== RCS file: RCS/n10.c,v retrieving revision 1.1 retrieving revision 1.2 diff -c2 -r1.1 -r1.2 *** /tmp/,RCSt1001198 Tue Aug 27 07:37:48 1985 --- /tmp/,RCSt2001198 Tue Aug 27 07:37:49 1985 *************** *** 82,88 } } ! ptout(i) ! int i; ! { *olinep++ = i; if(olinep >= &oline[LNSIZE])olinep--; --- 82,88 ----- } } ! ! #ifndef FAST ! ptout (i) int i; { *olinep++ = i; if(olinep >= &oline[LNSIZE])olinep--; *************** *** 88,91 if(olinep >= &oline[LNSIZE])olinep--; if((i&CMASK) != '\n')return; olinep--; lead += dip->blss + lss - t.Newline; --- 88,94 ----- if(olinep >= &oline[LNSIZE])olinep--; if((i&CMASK) != '\n')return; + #else FAST + _ptout_ () { + #endif FAST olinep--; lead += dip->blss + lss - t.Newline; *************** *** 144,147 } } if(xfont == ulfont){ for(k=w/t.Char;k>0;k--)oput('_'); --- 147,157 ----- } } + + /* + * This next section of code was moved to after the characters are + * output, so that underlining follows the characters, which is the + * way the Printronix printer likes it. 2/24/81 FLB + * + if(xfont == ulfont){ for(k=w/t.Char;k>0;k--)oput('_'); *************** *** 148,151 for(k=w/t.Char;k>0;k--)oput('\b'); } while(*codep != 0){ if(*codep & 0200){ --- 158,165 ----- for(k=w/t.Char;k>0;k--)oput('\b'); } + + * + */ + while(*codep != 0){ if(*codep & 0200){ *************** *** 161,164 } if(!w)for(k=phyw/t.Char;k>0;k--)oput('\b'); } } --- 175,189 ----- } if(!w)for(k=phyw/t.Char;k>0;k--)oput('\b'); + + /* + * Do underlining here. + * See previous comment as regards underlining. + */ + + if(xfont == ulfont){ + for(k=w/t.Char;k>0;k--)oput('\b'); + for(k=w/t.Char;k>0;k--)oput('_'); + } + } } =================================================================== RCS file: RCS/t10.c,v retrieving revision 1.1 retrieving revision 1.3 diff -c2 -r1.1 -r1.3 *** /tmp/,RCSt1001198 Tue Aug 27 07:37:52 1985 --- /tmp/,RCSt2001198 Tue Aug 27 07:37:53 1985 *************** *** 66,70 oput(0140); /*some initial lead*/ } ! ptout(i) int i; { --- 66,75 ----- oput(0140); /*some initial lead*/ } ! ! #ifndef FAST ! ptout (i) ! #else FAST ! _ptout_ (i) ! #endif FAST int i; { *************** *** 73,76 int psl[16]; if((i & CMASK) != '\n'){ *olinep++ = i; --- 78,82 ----- int psl[16]; + #ifndef FAST if((i & CMASK) != '\n'){ *olinep++ = i; *************** *** 77,80 return; } if(olinep == oline){ lead += lss; --- 83,87 ----- return; } + #endif FAST if(olinep == oline){ lead += lss; *************** *** 149,153 } ptout0(i) ! int i; { register j, k, w; --- 156,160 ----- } ptout0(i) ! register int i; { register j, k, w; *************** *** 275,279 while(k > 0){ if((i=127) > k)i = k; ! if(((j = (esct + i*(1-2*escm))) > (46*72+18-T_IESC)) || (j < 0))break; /* --- 282,290 ----- while(k > 0){ if((i=127) > k)i = k; ! /* ! * the magic number in the next line is ! * # of inches max line length * #picas/inch * #bu's/pica ! */ ! if(((j = (esct + i*(1-2*escm))) > (12*6*72+18-T_IESC)) || (j < 0))break; /* -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@maryland