Patch 8.2.0524

14 views
Skip to first unread message

Bram Moolenaar

unread,
Apr 6, 2020, 4:57:05 PM4/6/20
to vim...@googlegroups.com

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 -- Br...@Moolenaar.net -- 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 ///

Cesar

unread,
Apr 6, 2020, 5:27:44 PM4/6/20
to vim_dev
On 06/04/2020 03:56 p. m., Bram Moolenaar wrote:
>
> 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
> ***************
> [...]

I'm building vim 8.2.0524 with MinGW-W64 on Windows 7.
I get:

[...]
filepath.c: In function 'dos_expandpath':
filepath.c:3171:12: warning: statement with no effect [-Wunused-value]
p_alt == NULL;
^
filepath.c:3180:3: warning: suggest parentheses around '&&' within '||' [-Wparentheses]

if ((p[0] != '.' || starts_with_dot
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|| ((flags & EW_DODOT)
~~~~~~~~~~~~~~~~~~~~~~

&& 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)))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
))
~~
filepath.c:3187:55: error: expected statement before ')' token

&& fnamencmp(path + (s - buf), p, e - s) == 0)))
^
make: *** [gobji686/filepath.o] Error 1
Error by compiling gvim.exe


Many thanks in advance

--
Cesar

Reply all
Reply to author
Forward
0 new messages