# HG changeset patch # User Bram Moolenaar # Date 1607714103 -3600 # Node ID 2b2561f8602e03a3e052085a90aaf7a0b7cfb77e # Parent cf427490d44295b69918b9743519edddf74f17a5 patch 8.2.2129: MS-Windows: Checking if a file name is absolute is slow Commit: https://github.com/vim/vim/commit/0ea7421ae6618fe8efe9e3afc8fdcf7a4d89739a Author: Bram Moolenaar Date: Fri Dec 11 20:10:50 2020 +0100 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 https://github.com/vim/vim/issues/7033) diff --git a/src/os_mswin.c b/src/os_mswin.c --- a/src/os_mswin.c +++ b/src/os_mswin.c @@ -387,21 +387,13 @@ mch_FullName( int mch_isFullName(char_u *fname) { - // WinNT and later can use _MAX_PATH wide characters for a pathname, which - // means that the maximum pathname is _MAX_PATH * 3 bytes when 'enc' is - // UTF-8. - char szName[_MAX_PATH * 3 + 1]; - - // A name like "d:/foo" and "//server/share" is absolute - if ((fname[0] && fname[1] == ':' && (fname[2] == '/' || fname[2] == '\\')) - || (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; + // A name like "d:/foo" and "//server/share" is absolute. "d:foo" is not. + // Another way to check is to use mch_FullName() and see if the result is + // the same as the name or mch_FullName() fails. However, this has quite a + // bit of overhead, so let's not do that. + return ((ASCII_ISALPHA(fname[0]) && fname[1] == ':' + && (fname[2] == '/' || fname[2] == '\\')) + || (fname[0] == fname[1] && (fname[0] == '/' || fname[0] == '\\'))); } /* diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2129, +/**/ 2128, /**/ 2127,