mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
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 directory. (Nir Lichtman, closes #5883)
This commit is contained in:
parent
00d253e2b2
commit
c74fbfedfa
@ -64,6 +64,7 @@ get_short_pathname(char_u **fnamep, char_u **bufp, int *fnamelen)
|
|||||||
if (l != 0)
|
if (l != 0)
|
||||||
{
|
{
|
||||||
char_u *p = utf16_to_enc(newbuf, NULL);
|
char_u *p = utf16_to_enc(newbuf, NULL);
|
||||||
|
|
||||||
if (p != NULL)
|
if (p != NULL)
|
||||||
{
|
{
|
||||||
vim_free(*bufp);
|
vim_free(*bufp);
|
||||||
@ -3047,6 +3048,7 @@ dos_expandpath(
|
|||||||
WCHAR *wn = NULL; // UCS-2 name, NULL when not used.
|
WCHAR *wn = NULL; // UCS-2 name, NULL when not used.
|
||||||
char_u *matchname;
|
char_u *matchname;
|
||||||
int ok;
|
int ok;
|
||||||
|
char_u *p_alt;
|
||||||
|
|
||||||
// Expanding "**" may take a long time, check for CTRL-C.
|
// Expanding "**" may take a long time, check for CTRL-C.
|
||||||
if (stardepth > 0)
|
if (stardepth > 0)
|
||||||
@ -3161,9 +3163,15 @@ dos_expandpath(
|
|||||||
while (ok)
|
while (ok)
|
||||||
{
|
{
|
||||||
p = utf16_to_enc(wfb.cFileName, NULL); // p is allocated here
|
p = utf16_to_enc(wfb.cFileName, NULL); // p is allocated here
|
||||||
|
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
break; // out of memory
|
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
|
// Ignore entries starting with a dot, unless when asked for. Accept
|
||||||
// all entries found with "matchname".
|
// all entries found with "matchname".
|
||||||
if ((p[0] != '.' || starts_with_dot
|
if ((p[0] != '.' || starts_with_dot
|
||||||
@ -3171,14 +3179,18 @@ dos_expandpath(
|
|||||||
&& p[1] != NUL && (p[1] != '.' || p[2] != NUL)))
|
&& p[1] != NUL && (p[1] != '.' || p[2] != NUL)))
|
||||||
&& (matchname == NULL
|
&& (matchname == NULL
|
||||||
|| (regmatch.regprog != NULL
|
|| (regmatch.regprog != NULL
|
||||||
&& vim_regexec(®match, p, (colnr_T)0))
|
&& (vim_regexec(®match, p, (colnr_T)0)
|
||||||
|
|| (p_alt != NULL
|
||||||
|
&& vim_regexec(®match, p_alt, (colnr_T)0)))
|
||||||
|
))
|
||||||
|| ((flags & EW_NOTWILD)
|
|| ((flags & EW_NOTWILD)
|
||||||
&& fnamencmp(path + (s - buf), p, e - s) == 0)))
|
&& fnamencmp(path + (s - buf), p, e - s) == 0)))
|
||||||
{
|
{
|
||||||
STRCPY(s, p);
|
STRCPY(s, p);
|
||||||
len = (int)STRLEN(buf);
|
len = (int)STRLEN(buf);
|
||||||
|
|
||||||
if (starstar && stardepth < 100)
|
if (starstar && stardepth < 100
|
||||||
|
&& (wfb.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
||||||
{
|
{
|
||||||
// For "**" in the pattern first go deeper in the tree to
|
// For "**" in the pattern first go deeper in the tree to
|
||||||
// find matches.
|
// find matches.
|
||||||
@ -3207,24 +3219,9 @@ dos_expandpath(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vim_free(p_alt);
|
||||||
vim_free(p);
|
vim_free(p);
|
||||||
ok = FindNextFileW(hFind, &wfb);
|
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);
|
FindClose(hFind);
|
||||||
|
@ -738,6 +738,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
524,
|
||||||
/**/
|
/**/
|
||||||
523,
|
523,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user