mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
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)
This commit is contained in:
@@ -387,21 +387,13 @@ mch_FullName(
|
|||||||
int
|
int
|
||||||
mch_isFullName(char_u *fname)
|
mch_isFullName(char_u *fname)
|
||||||
{
|
{
|
||||||
// WinNT and later can use _MAX_PATH wide characters for a pathname, which
|
// A name like "d:/foo" and "//server/share" is absolute. "d:foo" is not.
|
||||||
// means that the maximum pathname is _MAX_PATH * 3 bytes when 'enc' is
|
// Another way to check is to use mch_FullName() and see if the result is
|
||||||
// UTF-8.
|
// the same as the name or mch_FullName() fails. However, this has quite a
|
||||||
char szName[_MAX_PATH * 3 + 1];
|
// bit of overhead, so let's not do that.
|
||||||
|
return ((ASCII_ISALPHA(fname[0]) && fname[1] == ':'
|
||||||
// A name like "d:/foo" and "//server/share" is absolute
|
&& (fname[2] == '/' || fname[2] == '\\'))
|
||||||
if ((fname[0] && fname[1] == ':' && (fname[2] == '/' || fname[2] == '\\'))
|
|| (fname[0] == fname[1] && (fname[0] == '/' || fname[0] == '\\')));
|
||||||
|| (fname[0] == fname[1] && (fname[0] == '/' || fname[0] == '\\')))
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
// A name that can't be made absolute probably isn't absolute.
|
|
||||||
if (mch_FullName(fname, (char_u *)szName, sizeof(szName) - 1, FALSE) == FAIL)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return pathcmp((const char *)fname, (const char *)szName, -1) == 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -750,6 +750,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 */
|
||||||
|
/**/
|
||||||
|
2129,
|
||||||
/**/
|
/**/
|
||||||
2128,
|
2128,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user