To: vim_dev@googlegroups.com Subject: Patch 8.2.0524 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ 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(®match, 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(®match, p, (colnr_T)0) ! || (p_alt != NULL ! && vim_regexec(®match, 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 -- Bram@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 ///