home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / old / 5.6.096 < prev    next >
Encoding:
Internet Message Format  |  2000-06-07  |  5.3 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 5.6.096
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. ------------
  6.  
  7. Patch 5.6.096
  8. Problem:    Unix: When editing many files, startup can be slow. (Paul
  9.         Ackersviller)
  10. Solution:   Halve the number of stat() calls used to add a file to the buffer
  11.         list.
  12. Files:        src/buffer.c
  13.  
  14.  
  15. *** ../vim-5.6.95/src/buffer.c    Sat Apr 15 18:05:18 2000
  16. --- src/buffer.c    Wed Jun  7 19:11:48 2000
  17. ***************
  18. *** 31,36 ****
  19. --- 31,37 ----
  20.   static char_u    *buflist_match_try __ARGS((vim_regexp *prog, char_u *name));
  21.   static void    buflist_setfpos __ARGS((BUF *, linenr_t, colnr_t));
  22.   #ifdef UNIX
  23. + static BUF    *buflist_findname_stat __ARGS((char_u *ffname, struct stat *st));
  24.   static int    otherfile_buf __ARGS((BUF *buf, char_u *ffname, struct stat *stp));
  25.   static void    buf_setino __ARGS((BUF *buf));
  26.   static int    buf_same_ino __ARGS((BUF *buf, struct stat *stp));
  27. ***************
  28. *** 802,814 ****
  29.       int        use_curbuf;
  30.   {
  31.       BUF        *buf;
  32.   
  33.       fname_expand(&ffname, &sfname);    /* will allocate ffname */
  34.   
  35.       /*
  36.        * If file name already exists in the list, update the entry.
  37.        */
  38. !     if (ffname != NULL && (buf = buflist_findname(ffname)) != NULL)
  39.       {
  40.       vim_free(ffname);
  41.       if (lnum != 0)
  42. --- 792,818 ----
  43.       int        use_curbuf;
  44.   {
  45.       BUF        *buf;
  46. + #ifdef UNIX
  47. +     struct stat    st;
  48. + #endif
  49.   
  50.       fname_expand(&ffname, &sfname);    /* will allocate ffname */
  51.   
  52. + #ifdef UNIX
  53. +     if (sfname == NULL || mch_stat((char *)sfname, &st) < 0)
  54. +     st.st_dev = (unsigned)-1;
  55. + #endif
  56.       /*
  57.        * If file name already exists in the list, update the entry.
  58.        */
  59. !     if (ffname != NULL && (buf =
  60. ! #ifdef UNIX
  61. !         buflist_findname_stat(ffname, &st)
  62. ! #else
  63. !         buflist_findname(ffname)
  64. ! #endif
  65. !         ) != NULL)
  66.       {
  67.       vim_free(ffname);
  68.       if (lnum != 0)
  69. ***************
  70. *** 917,923 ****
  71.   
  72.       buf->b_fname = buf->b_sfname;
  73.   #ifdef UNIX
  74. !     buf_setino(buf);
  75.   #endif
  76.       buf->b_u_synced = TRUE;
  77.       buf->b_flags = BF_CHECK_RO | BF_NEVERLOADED;
  78. --- 921,933 ----
  79.   
  80.       buf->b_fname = buf->b_sfname;
  81.   #ifdef UNIX
  82. !     if (st.st_dev == (unsigned)-1)
  83. !     buf->b_dev = -1;
  84. !     else
  85. !     {
  86. !     buf->b_dev = st.st_dev;
  87. !     buf->b_ino = st.st_ino;
  88. !     }
  89.   #endif
  90.       buf->b_u_synced = TRUE;
  91.       buf->b_flags = BF_CHECK_RO | BF_NEVERLOADED;
  92. ***************
  93. *** 1093,1110 ****
  94.   buflist_findname(ffname)
  95.       char_u    *ffname;
  96.   {
  97. -     BUF        *buf;
  98.   #ifdef UNIX
  99.       struct stat st;
  100.   
  101.       if (mch_stat((char *)ffname, &st) < 0)
  102.       st.st_dev = (unsigned)-1;
  103.   #endif
  104.   
  105.       for (buf = firstbuf; buf != NULL; buf = buf->b_next)
  106.       if (!otherfile_buf(buf, ffname
  107.   #ifdef UNIX
  108. !             , &st
  109.   #endif
  110.               ))
  111.           return buf;
  112. --- 1103,1132 ----
  113.   buflist_findname(ffname)
  114.       char_u    *ffname;
  115.   {
  116.   #ifdef UNIX
  117.       struct stat st;
  118.   
  119.       if (mch_stat((char *)ffname, &st) < 0)
  120.       st.st_dev = (unsigned)-1;
  121. +     return buflist_findname_stat(ffname, &st);
  122. + }
  123. + /*
  124. +  * Same as buflist_findname(), but pass the stat structure to avoid getting it
  125. +  * twice for the same file.
  126. +  */
  127. +     static BUF *
  128. + buflist_findname_stat(ffname, stp)
  129. +     char_u    *ffname;
  130. +     struct stat    *stp;
  131. + {
  132.   #endif
  133. +     BUF        *buf;
  134.   
  135.       for (buf = firstbuf; buf != NULL; buf = buf->b_next)
  136.       if (!otherfile_buf(buf, ffname
  137.   #ifdef UNIX
  138. !             , stp
  139.   #endif
  140.               ))
  141.           return buf;
  142. ***************
  143. *** 1536,1542 ****
  144.       char_u *ffname, *sfname;
  145.       int        message;
  146.   {
  147. !     BUF        *buf;
  148.   
  149.       if (ffname == NULL || *ffname == NUL)
  150.       {
  151. --- 1558,1567 ----
  152.       char_u *ffname, *sfname;
  153.       int        message;
  154.   {
  155. !     BUF        *buf;
  156. ! #ifdef UNIX
  157. !     struct stat st;
  158. ! #endif
  159.   
  160.       if (ffname == NULL || *ffname == NUL)
  161.       {
  162. ***************
  163. *** 1544,1549 ****
  164. --- 1569,1577 ----
  165.       vim_free(curbuf->b_sfname);
  166.       curbuf->b_ffname = NULL;
  167.       curbuf->b_sfname = NULL;
  168. + #ifdef UNIX
  169. +     st.st_dev = (unsigned)-1;
  170. + #endif
  171.       }
  172.       else
  173.       {
  174. ***************
  175. *** 1562,1568 ****
  176. --- 1590,1602 ----
  177.        * - if the buffer is loaded, fail
  178.        * - if the buffer is not loaded, delete it from the list
  179.        */
  180. + #ifdef UNIX
  181. +     if (mch_stat((char *)ffname, &st) < 0)
  182. +         st.st_dev = (unsigned)-1;
  183. +     buf = buflist_findname_stat(ffname, &st);
  184. + #else
  185.       buf = buflist_findname(ffname);
  186. + #endif
  187.       if (buf != NULL && buf != curbuf)
  188.       {
  189.           if (buf->b_ml.ml_mfp != NULL)    /* it's loaded, fail */
  190. ***************
  191. *** 1588,1594 ****
  192.       }
  193.       curbuf->b_fname = curbuf->b_sfname;
  194.   #ifdef UNIX
  195. !     buf_setino(curbuf);
  196.   #endif
  197.   
  198.   #ifndef SHORT_FNAME
  199. --- 1622,1634 ----
  200.       }
  201.       curbuf->b_fname = curbuf->b_sfname;
  202.   #ifdef UNIX
  203. !     if (st.st_dev == (unsigned)-1)
  204. !     curbuf->b_dev = -1;
  205. !     else
  206. !     {
  207. !     curbuf->b_dev = st.st_dev;
  208. !     curbuf->b_ino = st.st_ino;
  209. !     }
  210.   #endif
  211.   
  212.   #ifndef SHORT_FNAME
  213. *** ../vim-5.6.95/src/version.c    Thu Jun  8 21:01:00 2000
  214. --- src/version.c    Thu Jun  8 21:01:56 2000
  215. ***************
  216. *** 420,421 ****
  217. --- 420,423 ----
  218.   {   /* Add new patch number below this line */
  219. + /**/
  220. +     96,
  221.   /**/
  222.  
  223. -- 
  224. Engineers are widely recognized as superior marriage material: intelligent,
  225. dependable, employed, honest, and handy around the house.
  226.                 (Scott Adams - The Dilbert principle)
  227.  
  228. /-/-- Bram Moolenaar --- Bram@moolenaar.net --- http://www.moolenaar.net --\-\
  229. \-\-- Vim: http://www.vim.org ---- ICCF Holland: http://www.vim.org/iccf --/-/
  230.