• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Revisionce463840c82629f275c07bec92f9c5623c41d6cf (tree)
Zeit2020-04-07 06:00:29
AutorBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Log Message

patch 8.2.0524: Win32: searching for file matches is slow

Commit: https://github.com/vim/vim/commit/c74fbfedfa2df384cca5f6763e2c9e5c0ca6d513
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Apr 6 22:56:28 2020 +0200

patch 8.2.0524: Win32: searching for file matches is slow
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
                1. (Nir Lichtman, closes #5883)

Ändern Zusammenfassung

Diff

diff -r 7d46edfd1c55 -r ce463840c826 src/filepath.c
--- a/src/filepath.c Mon Apr 06 22:15:40 2020 +0200
+++ b/src/filepath.c Mon Apr 06 23:00:29 2020 +0200
@@ -64,6 +64,7 @@
6464 if (l != 0)
6565 {
6666 char_u *p = utf16_to_enc(newbuf, NULL);
67+
6768 if (p != NULL)
6869 {
6970 vim_free(*bufp);
@@ -3047,6 +3048,7 @@
30473048 WCHAR *wn = NULL; // UCS-2 name, NULL when not used.
30483049 char_u *matchname;
30493050 int ok;
3051+ char_u *p_alt;
30503052
30513053 // Expanding "**" may take a long time, check for CTRL-C.
30523054 if (stardepth > 0)
@@ -3161,9 +3163,15 @@
31613163 while (ok)
31623164 {
31633165 p = utf16_to_enc(wfb.cFileName, NULL); // p is allocated here
3166+
31643167 if (p == NULL)
31653168 break; // out of memory
31663169
3170+ if (*wfb.cAlternateFileName == NUL)
3171+ p_alt == NULL;
3172+ else
3173+ p_alt = utf16_to_enc(wfb.cAlternateFileName, NULL);
3174+
31673175 // Ignore entries starting with a dot, unless when asked for. Accept
31683176 // all entries found with "matchname".
31693177 if ((p[0] != '.' || starts_with_dot
@@ -3171,14 +3179,18 @@
31713179 && p[1] != NUL && (p[1] != '.' || p[2] != NUL)))
31723180 && (matchname == NULL
31733181 || (regmatch.regprog != NULL
3174- && vim_regexec(&regmatch, p, (colnr_T)0))
3182+ && (vim_regexec(&regmatch, p, (colnr_T)0)
3183+ || (p_alt != NULL
3184+ && vim_regexec(&regmatch, p_alt, (colnr_T)0)))
3185+ ))
31753186 || ((flags & EW_NOTWILD)
31763187 && fnamencmp(path + (s - buf), p, e - s) == 0)))
31773188 {
31783189 STRCPY(s, p);
31793190 len = (int)STRLEN(buf);
31803191
3181- if (starstar && stardepth < 100)
3192+ if (starstar && stardepth < 100
3193+ && (wfb.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
31823194 {
31833195 // For "**" in the pattern first go deeper in the tree to
31843196 // find matches.
@@ -3207,24 +3219,9 @@
32073219 }
32083220 }
32093221
3222+ vim_free(p_alt);
32103223 vim_free(p);
32113224 ok = FindNextFileW(hFind, &wfb);
3212-
3213- // If no more matches and no match was used, try expanding the name
3214- // itself. Finds the long name of a short filename.
3215- if (!ok && matchname != NULL && gap->ga_len == start_len)
3216- {
3217- STRCPY(s, matchname);
3218- FindClose(hFind);
3219- vim_free(wn);
3220- wn = enc_to_utf16(buf, NULL);
3221- if (wn != NULL)
3222- hFind = FindFirstFileW(wn, &wfb);
3223- else
3224- hFind = INVALID_HANDLE_VALUE;
3225- ok = (hFind != INVALID_HANDLE_VALUE);
3226- VIM_CLEAR(matchname);
3227- }
32283225 }
32293226
32303227 FindClose(hFind);
diff -r 7d46edfd1c55 -r ce463840c826 src/version.c
--- a/src/version.c Mon Apr 06 22:15:40 2020 +0200
+++ b/src/version.c Mon Apr 06 23:00:29 2020 +0200
@@ -739,6 +739,8 @@
739739 static int included_patches[] =
740740 { /* Add new patch number below this line */
741741 /**/
742+ 524,
743+/**/
742744 523,
743745 /**/
744746 522,
Show on old repository browser