home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume1 / rn / patch14 < prev    next >
Encoding:
Text File  |  1986-11-30  |  11.1 KB  |  468 lines

  1. System: rn version 4.3
  2. Patch #: 14
  3. Priority: ENHANCEMENT
  4. Subject: rn -c speedup
  5. >From: mark@cbosgd.UUCP (Mark Horton), lwall@sdcrdcf.UUCP (Larry Wall)
  6.  
  7. Description:
  8.     Mark mentioned that he didn't want to put "rn -c" into his
  9.     system-wide login profile because it was kind of slow, and he
  10.     suggested that it might be speedupable.  Okay, here it is.
  11.     The following patches make "rn -c" run between two and three
  12.     times faster on our machine.  These figures are for comparison
  13.     only and may vary depending on the environment and your driving
  14.     habits.
  15.  
  16. Fix:    From rn, say "| patch -d DIR", where DIR is your rn source directory.
  17.     Outside of rn, say "cd DIR; patch <thisarticle".  If you don't have
  18.     the patch program, apply the following by hand, or get patch.
  19.     (Has anyone really made it this far without patch?)
  20.  
  21.     If patch indicates that patchlevel is the wrong version, you may need
  22.     to apply one or more previous patches, or the patch may already
  23.     have been applied.  See the patchlevel file to find out what has or
  24.     has not been applied.  In any event, don't continue with the patch.
  25.  
  26. Index: patchlevel
  27. Prereq: 13
  28. 1c1
  29. < Patch #: 13
  30. ---
  31. > Patch #: 14
  32.  
  33. Index: init.c
  34. Prereq: 4.3
  35. *** init.c.old    Tue May 21 13:38:34 1985
  36. --- init.c    Tue May 21 13:38:37 1985
  37. ***************
  38. *** 1,4
  39. ! /* $Header: init.c,v 4.3 85/05/01 16:16:13 lwall Exp $
  40.    *
  41.    * $Log:    init.c,v $
  42.    * Revision 4.3  85/05/01  16:16:13  lwall
  43.  
  44. --- 1,4 -----
  45. ! /* $Header: init.c,v 4.3.1.2 85/05/21 14:22:46 lwall Exp $
  46.    *
  47.    * $Log:    init.c,v $
  48.    * Revision 4.3.1.2  85/05/21  14:22:46  lwall
  49. ***************
  50. *** 1,6
  51.   /* $Header: init.c,v 4.3 85/05/01 16:16:13 lwall Exp $
  52.    *
  53.    * $Log:    init.c,v $
  54.    * Revision 4.3  85/05/01  16:16:13  lwall
  55.    * Baseline for release with 4.3bsd.
  56.    * 
  57.  
  58. --- 1,12 -----
  59.   /* $Header: init.c,v 4.3.1.2 85/05/21 14:22:46 lwall Exp $
  60.    *
  61.    * $Log:    init.c,v $
  62. +  * Revision 4.3.1.2  85/05/21  14:22:46  lwall
  63. +  * Sped up "rn -c" by avoiding unnecessary initialization.
  64. +  * 
  65. +  * Revision 4.3.1.1  85/05/10  11:33:39  lwall
  66. +  * Branch for patches.
  67. +  * 
  68.    * Revision 4.3  85/05/01  16:16:13  lwall
  69.    * Baseline for release with 4.3bsd.
  70.    * 
  71. ***************
  72. *** 80,86
  73.       
  74.       /* now make sure we have a current working directory */
  75.   
  76. !     cwd_check();
  77.       
  78.       /* now that we know where to save things, cd to news directory */
  79.   
  80.  
  81. --- 86,93 -----
  82.       
  83.       /* now make sure we have a current working directory */
  84.   
  85. !     if (!checkflag)
  86. !     cwd_check();
  87.       
  88.       /* now that we know where to save things, cd to news directory */
  89.   
  90. ***************
  91. *** 96,102
  92.   
  93.       /* get info on last rn run, if any */
  94.   
  95. !     last_init(tcbuf);
  96.   
  97.       free(tcbuf);            /* recover 1024 bytes */
  98.   
  99.  
  100. --- 103,110 -----
  101.   
  102.       /* get info on last rn run, if any */
  103.   
  104. !     if (!checkflag)
  105. !     last_init(tcbuf);
  106.   
  107.       free(tcbuf);            /* recover 1024 bytes */
  108.   
  109. ***************
  110. *** 102,108
  111.   
  112.       /* make sure we are the right version */
  113.   
  114. !     version_check();
  115.   
  116.       /* make sure we are the sole possessors of .newsrc */
  117.   
  118.  
  119. --- 110,117 -----
  120.   
  121.       /* make sure we are the right version */
  122.   
  123. !     if (!checkflag)
  124. !     version_check();
  125.   
  126.       /* make sure we are the sole possessors of .newsrc */
  127.   
  128. ***************
  129. *** 106,112
  130.   
  131.       /* make sure we are the sole possessors of .newsrc */
  132.   
  133. !     lock_check();
  134.   
  135.       /* check for news news */
  136.   
  137.  
  138. --- 115,122 -----
  139.   
  140.       /* make sure we are the sole possessors of .newsrc */
  141.   
  142. !     if (!checkflag)
  143. !     lock_check();
  144.   
  145.       /* check for news news */
  146.   
  147. ***************
  148. *** 110,116
  149.   
  150.       /* check for news news */
  151.   
  152. !     newsnews_check();
  153.   
  154.       /* open active file, etc. */
  155.   
  156.  
  157. --- 120,127 -----
  158.   
  159.       /* check for news news */
  160.   
  161. !     if (!checkflag)
  162. !     newsnews_check();
  163.   
  164.       /* open active file, etc. */
  165.   
  166. ***************
  167. *** 214,220
  168.       tmpfp = fopen(lockname,"r");
  169.       if (tmpfp != Nullfp) {
  170.           int processnum;
  171.           fgets(buf,LBUFLEN,tmpfp);
  172.           fclose(tmpfp);
  173.           processnum = atoi(buf);
  174.  
  175. --- 225,231 -----
  176.       tmpfp = fopen(lockname,"r");
  177.       if (tmpfp != Nullfp) {
  178.           int processnum;
  179. !     
  180.           fgets(buf,LBUFLEN,tmpfp);
  181.           fclose(tmpfp);
  182.           processnum = atoi(buf);
  183. ***************
  184. *** 285,291
  185.   {
  186.       char *newsnewsname = filexp(NEWSNEWSNAME);
  187.   
  188. !     if (!checkflag && (tmpfp = fopen(newsnewsname,"r")) != Nullfp) {
  189.       fstat(tmpfp->_file,&filestat);
  190.       if (filestat.st_mtime > lasttime) {
  191.           while (fgets(buf,sizeof(buf),tmpfp) != Nullch)
  192.  
  193. --- 296,302 -----
  194.   {
  195.       char *newsnewsname = filexp(NEWSNEWSNAME);
  196.   
  197. !     if ((tmpfp = fopen(newsnewsname,"r")) != Nullfp) {
  198.       fstat(tmpfp->_file,&filestat);
  199.       if (filestat.st_mtime > lasttime) {
  200.           while (fgets(buf,sizeof(buf),tmpfp) != Nullch)
  201.  
  202. Index: intrp.c
  203. Prereq: 4.3.1.3
  204. *** intrp.c.old    Tue May 21 13:39:24 1985
  205. --- intrp.c    Tue May 21 13:39:37 1985
  206. ***************
  207. *** 1,4
  208. ! /* $Header: intrp.c,v 4.3.1.3 85/05/17 10:37:11 lwall Exp $
  209.    *
  210.    * $Log:    intrp.c,v $
  211.    * Revision 4.3.1.3  85/05/17  10:37:11  lwall
  212.  
  213. --- 1,4 -----
  214. ! /* $Header: intrp.c,v 4.3.1.4 85/05/21 13:35:21 lwall Exp $
  215.    *
  216.    * $Log:    intrp.c,v $
  217.    * Revision 4.3.1.4  85/05/21  13:35:21  lwall
  218. ***************
  219. *** 1,6
  220.   /* $Header: intrp.c,v 4.3.1.3 85/05/17 10:37:11 lwall Exp $
  221.    *
  222.    * $Log:    intrp.c,v $
  223.    * Revision 4.3.1.3  85/05/17  10:37:11  lwall
  224.    * Fixed & substitution to capitalize last name too.
  225.    * 
  226.  
  227. --- 1,9 -----
  228.   /* $Header: intrp.c,v 4.3.1.4 85/05/21 13:35:21 lwall Exp $
  229.    *
  230.    * $Log:    intrp.c,v $
  231. +  * Revision 4.3.1.4  85/05/21  13:35:21  lwall
  232. +  * Sped up "rn -c" by not doing unnecessary initialization.
  233. +  * 
  234.    * Revision 4.3.1.3  85/05/17  10:37:11  lwall
  235.    * Fixed & substitution to capitalize last name too.
  236.    * 
  237. ***************
  238. *** 83,91
  239.   
  240.       spool = savestr(filexp(SPOOL));    /* usually /usr/spool/news */
  241.       
  242. -     getwd(tcbuf);            /* find working directory name */
  243. -     origdir = savestr(tcbuf);        /* and remember it */
  244. -     
  245.       /* get environmental stuff */
  246.   
  247.       /* get home directory */
  248.  
  249. --- 86,91 -----
  250.   
  251.       spool = savestr(filexp(SPOOL));    /* usually /usr/spool/news */
  252.       
  253.       /* get environmental stuff */
  254.   
  255.       /* get home directory */
  256. ***************
  257. *** 105,110
  258.       if (logname == Nullch)
  259.       logname = savestr(getlogin());
  260.   #endif
  261.   
  262.       /* get the real name of the person (%N) */
  263.       /* Must be done after logname is read in because BERKNAMES uses that */
  264.  
  265. --- 105,115 -----
  266.       if (logname == Nullch)
  267.       logname = savestr(getlogin());
  268.   #endif
  269. +     
  270. +     if (checkflag)            /* that getwd below takes ~1/3 sec. */
  271. +     return;                /* and we do not need it for -c */
  272. +     getwd(tcbuf);            /* find working directory name */
  273. +     origdir = savestr(tcbuf);        /* and remember it */
  274.   
  275.       /* get the real name of the person (%N) */
  276.       /* Must be done after logname is read in because BERKNAMES uses that */
  277.  
  278. Index: rcstuff.c
  279. Prereq: 4.3
  280. *** rcstuff.c.old    Tue May 21 13:38:02 1985
  281. --- rcstuff.c    Tue May 21 13:38:10 1985
  282. ***************
  283. *** 1,4
  284. ! /* $Header: rcstuff.c,v 4.3 85/05/01 11:45:56 lwall Exp $
  285.    *
  286.    * $Log:    rcstuff.c,v $
  287.    * Revision 4.3  85/05/01  11:45:56  lwall
  288.  
  289. --- 1,4 -----
  290. ! /* $Header: rcstuff.c,v 4.3.1.2 85/05/17 11:40:08 lwall Exp $
  291.    *
  292.    * $Log:    rcstuff.c,v $
  293.    * Revision 4.3.1.2  85/05/17  11:40:08  lwall
  294. ***************
  295. *** 1,6
  296.   /* $Header: rcstuff.c,v 4.3 85/05/01 11:45:56 lwall Exp $
  297.    *
  298.    * $Log:    rcstuff.c,v $
  299.    * Revision 4.3  85/05/01  11:45:56  lwall
  300.    * Baseline for release with 4.3bsd.
  301.    * 
  302.  
  303. --- 1,12 -----
  304.   /* $Header: rcstuff.c,v 4.3.1.2 85/05/17 11:40:08 lwall Exp $
  305.    *
  306.    * $Log:    rcstuff.c,v $
  307. +  * Revision 4.3.1.2  85/05/17  11:40:08  lwall
  308. +  * Sped up "rn -c" by not mallocing unnecessarily.
  309. +  * 
  310. +  * Revision 4.3.1.1  85/05/10  11:37:18  lwall
  311. +  * Branch for patches.
  312. +  * 
  313.    * Revision 4.3  85/05/01  11:45:56  lwall
  314.    * Baseline for release with 4.3bsd.
  315.    * 
  316. ***************
  317. *** 84,90
  318.       else
  319.           softptr[newng] = 0;
  320.       some_buf[--length] = '\0';    /* wipe out newline */
  321. !     if (some_buf == buf) {
  322.           rcline[newng] = savestr(some_buf);
  323.                       /* make a semipermanent copy */
  324.       }
  325.  
  326. --- 90,98 -----
  327.       else
  328.           softptr[newng] = 0;
  329.       some_buf[--length] = '\0';    /* wipe out newline */
  330. !     if (checkflag)            /* no extra mallocs for -c */
  331. !         rcline[newng] = some_buf;
  332. !     else if (some_buf == buf) {
  333.           rcline[newng] = savestr(some_buf);
  334.                       /* make a semipermanent copy */
  335.       }
  336. ***************
  337. *** 110,116
  338.           continue;
  339.       }
  340.       for (s = rcline[newng]; *s && *s != ':' && *s != NEGCHAR; s++) ;
  341. !     if (!*s) {
  342.   #ifndef lint
  343.           rcline[newng] = saferealloc(rcline[newng],(MEM_SIZE)length+2);
  344.   #endif lint
  345.  
  346. --- 118,124 -----
  347.           continue;
  348.       }
  349.       for (s = rcline[newng]; *s && *s != ':' && *s != NEGCHAR; s++) ;
  350. !     if (!*s && !checkflag) {
  351.   #ifndef lint
  352.           rcline[newng] = saferealloc(rcline[newng],(MEM_SIZE)length+2);
  353.   #endif lint
  354.  
  355. Index: sw.c
  356. Prereq: 4.3
  357. *** sw.c.old    Tue May 21 13:38:54 1985
  358. --- sw.c    Tue May 21 13:38:57 1985
  359. ***************
  360. *** 1,4
  361. ! /* $Header: sw.c,v 4.3 85/05/01 11:50:54 lwall Exp $
  362.    *
  363.    * $Log:    sw.c,v $
  364.    * Revision 4.3  85/05/01  11:50:54  lwall
  365.  
  366. --- 1,4 -----
  367. ! /* $Header: sw.c,v 4.3.1.2 85/05/21 13:36:23 lwall Exp $
  368.    *
  369.    * $Log:    sw.c,v $
  370.    * Revision 4.3.1.2  85/05/21  13:36:23  lwall
  371. ***************
  372. *** 1,6
  373.   /* $Header: sw.c,v 4.3 85/05/01 11:50:54 lwall Exp $
  374.    *
  375.    * $Log:    sw.c,v $
  376.    * Revision 4.3  85/05/01  11:50:54  lwall
  377.    * Baseline for release with 4.3bsd.
  378.    * 
  379.  
  380. --- 1,12 -----
  381.   /* $Header: sw.c,v 4.3.1.2 85/05/21 13:36:23 lwall Exp $
  382.    *
  383.    * $Log:    sw.c,v $
  384. +  * Revision 4.3.1.2  85/05/21  13:36:23  lwall
  385. +  * Sped up "rn -c" by not doing unnecessary initialization.
  386. +  * 
  387. +  * Revision 4.3.1.1  85/05/10  11:40:38  lwall
  388. +  * Branch for patches.
  389. +  * 
  390.    * Revision 4.3  85/05/01  11:50:54  lwall
  391.    * Baseline for release with 4.3bsd.
  392.    * 
  393. ***************
  394. *** 25,30
  395.   {
  396.       register int i;
  397.   
  398.       interp(*tcbufptr,1024,GLOBINIT);
  399.       sw_file(tcbufptr,FALSE);
  400.       safecpy(*tcbufptr,getenv("RNINIT"),1024);
  401.  
  402. --- 31,38 -----
  403.   {
  404.       register int i;
  405.   
  406. +     if (argc >= 2 && strEQ(argv[1],"-c"))
  407. +     checkflag=TRUE;            /* so we can optimize for -c */
  408.       interp(*tcbufptr,1024,GLOBINIT);
  409.       sw_file(tcbufptr,FALSE);
  410.       safecpy(*tcbufptr,getenv("RNINIT"),1024);
  411. ***************
  412. *** 161,166
  413.           break;
  414.   #endif
  415.       case '/':
  416.   #ifdef SETENV
  417.           setenv("SAVEDIR",  upordown ? "%p/%c" : "%p" );
  418.           setenv("SAVENAME", upordown ? "%a"    : "%^C");
  419.  
  420. --- 169,176 -----
  421.           break;
  422.   #endif
  423.       case '/':
  424. +         if (checkflag)
  425. +         break;
  426.   #ifdef SETENV
  427.           setenv("SAVEDIR",  upordown ? "%p/%c" : "%p" );
  428.           setenv("SAVENAME", upordown ? "%a"    : "%^C");
  429. ***************
  430. *** 177,182
  431.           docheckwhen = atoi(s);
  432.           break;
  433.       case 'd': {
  434.           s++;
  435.           if (*s == '=') s++;
  436.           if (cwd) {
  437.  
  438. --- 187,194 -----
  439.           docheckwhen = atoi(s);
  440.           break;
  441.       case 'd': {
  442. +         if (checkflag)
  443. +         break;
  444.           s++;
  445.           if (*s == '=') s++;
  446.           if (cwd) {
  447. ***************
  448. *** 237,242
  449.           char *t;
  450.           int flag = (*s == 'h' ? HT_HIDE : HT_MAGIC);
  451.           
  452.           s++;
  453.           len = strlen(s);
  454.           for (t=s; *t; t++)
  455.  
  456. --- 249,256 -----
  457.           char *t;
  458.           int flag = (*s == 'h' ? HT_HIDE : HT_MAGIC);
  459.           
  460. +         if (checkflag)
  461. +         break;
  462.           s++;
  463.           len = strlen(s);
  464.           for (t=s; *t; t++)
  465.  
  466.  
  467.