Skip to content

Commit 0ea7421

Browse files
committed
patch 8.2.2129: MS-Windows: Checking if a file name is absolute is slow
Problem: MS-Windows: Checking if a file name is absolute is slow. Solution: Do not use mch_FullName(). (closes #7033)
1 parent 100118c commit 0ea7421

2 files changed

Lines changed: 9 additions & 15 deletions

File tree

src/os_mswin.c

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -387,21 +387,13 @@ mch_FullName(
387387
int
388388
mch_isFullName(char_u *fname)
389389
{
390-
// WinNT and later can use _MAX_PATH wide characters for a pathname, which
391-
// means that the maximum pathname is _MAX_PATH * 3 bytes when 'enc' is
392-
// UTF-8.
393-
char szName[_MAX_PATH * 3 + 1];
394-
395-
// A name like "d:/foo" and "//server/share" is absolute
396-
if ((fname[0] && fname[1] == ':' && (fname[2] == '/' || fname[2] == '\\'))
397-
|| (fname[0] == fname[1] && (fname[0] == '/' || fname[0] == '\\')))
398-
return TRUE;
399-
400-
// A name that can't be made absolute probably isn't absolute.
401-
if (mch_FullName(fname, (char_u *)szName, sizeof(szName) - 1, FALSE) == FAIL)
402-
return FALSE;
403-
404-
return pathcmp((const char *)fname, (const char *)szName, -1) == 0;
390+
// A name like "d:/foo" and "//server/share" is absolute. "d:foo" is not.
391+
// Another way to check is to use mch_FullName() and see if the result is
392+
// the same as the name or mch_FullName() fails. However, this has quite a
393+
// bit of overhead, so let's not do that.
394+
return ((ASCII_ISALPHA(fname[0]) && fname[1] == ':'
395+
&& (fname[2] == '/' || fname[2] == '\\'))
396+
|| (fname[0] == fname[1] && (fname[0] == '/' || fname[0] == '\\')));
405397
}
406398

407399
/*

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2129,
753755
/**/
754756
2128,
755757
/**/

0 commit comments

Comments
 (0)