Patch 8.2.0524
Problem:    Win32: searching for file matches is slow.
Solution:   Instead of making another round to find any short filename, check
            for the short name right away. Avoid using an ordinary file like a
            directory.  (Nir Lichtman, closes #5883)
Files:      src/filepath.c


*** ../vim-8.2.0523/src/filepath.c      2020-04-06 21:12:38.809322010 +0200
--- src/filepath.c      2020-04-06 22:54:50.647590386 +0200
***************
*** 64,69 ****
--- 64,70 ----
      if (l != 0)
      {
        char_u *p = utf16_to_enc(newbuf, NULL);
+ 
        if (p != NULL)
        {
            vim_free(*bufp);
***************
*** 3047,3052 ****
--- 3048,3054 ----
      WCHAR             *wn = NULL;     // UCS-2 name, NULL when not used.
      char_u            *matchname;
      int                       ok;
+     char_u            *p_alt;
  
      // Expanding "**" may take a long time, check for CTRL-C.
      if (stardepth > 0)
***************
*** 3161,3169 ****
--- 3163,3177 ----
      while (ok)
      {
        p = utf16_to_enc(wfb.cFileName, NULL);   // p is allocated here
+ 
        if (p == NULL)
            break;  // out of memory
  
+       if (*wfb.cAlternateFileName == NUL)
+           p_alt == NULL;
+       else
+           p_alt = utf16_to_enc(wfb.cAlternateFileName, NULL);
+ 
        // Ignore entries starting with a dot, unless when asked for.  Accept
        // all entries found with "matchname".
        if ((p[0] != '.' || starts_with_dot
***************
*** 3171,3184 ****
                             && p[1] != NUL && (p[1] != '.' || p[2] != NUL)))
                && (matchname == NULL
                  || (regmatch.regprog != NULL
!                                    && vim_regexec(&regmatch, p, (colnr_T)0))
                  || ((flags & EW_NOTWILD)
                     && fnamencmp(path + (s - buf), p, e - s) == 0)))
        {
            STRCPY(s, p);
            len = (int)STRLEN(buf);
  
!           if (starstar && stardepth < 100)
            {
                // For "**" in the pattern first go deeper in the tree to
                // find matches.
--- 3179,3196 ----
                             && p[1] != NUL && (p[1] != '.' || p[2] != NUL)))
                && (matchname == NULL
                  || (regmatch.regprog != NULL
!                    && (vim_regexec(&regmatch, p, (colnr_T)0)
!                        || (p_alt != NULL
!                                && vim_regexec(&regmatch, p_alt, (colnr_T)0)))
!                    ))
                  || ((flags & EW_NOTWILD)
                     && fnamencmp(path + (s - buf), p, e - s) == 0)))
        {
            STRCPY(s, p);
            len = (int)STRLEN(buf);
  
!           if (starstar && stardepth < 100
!                         && (wfb.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
            {
                // For "**" in the pattern first go deeper in the tree to
                // find matches.
***************
*** 3207,3230 ****
            }
        }
  
        vim_free(p);
        ok = FindNextFileW(hFind, &wfb);
- 
-       // If no more matches and no match was used, try expanding the name
-       // itself.  Finds the long name of a short filename.
-       if (!ok && matchname != NULL && gap->ga_len == start_len)
-       {
-           STRCPY(s, matchname);
-           FindClose(hFind);
-           vim_free(wn);
-           wn = enc_to_utf16(buf, NULL);
-           if (wn != NULL)
-               hFind = FindFirstFileW(wn, &wfb);
-           else
-               hFind = INVALID_HANDLE_VALUE;
-           ok = (hFind != INVALID_HANDLE_VALUE);
-           VIM_CLEAR(matchname);
-       }
      }
  
      FindClose(hFind);
--- 3219,3227 ----
            }
        }
  
+       vim_free(p_alt);
        vim_free(p);
        ok = FindNextFileW(hFind, &wfb);
      }
  
      FindClose(hFind);
*** ../vim-8.2.0523/src/version.c       2020-04-06 22:12:57.145652827 +0200
--- src/version.c       2020-04-06 22:55:23.907516645 +0200
***************
*** 740,741 ****
--- 740,743 ----
  {   /* Add new patch number below this line */
+ /**/
+     524,
  /**/

-- 
Yesterday, all my deadlines seemed so far away
now it looks as though it's freeze in four days
oh I believe in cvs..
    [ CVS log "Beatles style" for FreeBSD ports/INDEX, Satoshi Asami ]

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202004062056.036KuwCG031993%40masaka.moolenaar.net.

Raspunde prin e-mail lui