mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
updated for version 7.3.1175
Problem: Using isalpha() and isalnum() can be slow. Solution: Use range checks. (Mike Williams)
This commit is contained in:
@@ -3120,7 +3120,7 @@ modifier_len(cmd)
|
|||||||
for (j = 0; p[j] != NUL; ++j)
|
for (j = 0; p[j] != NUL; ++j)
|
||||||
if (p[j] != cmdmods[i].name[j])
|
if (p[j] != cmdmods[i].name[j])
|
||||||
break;
|
break;
|
||||||
if (!isalpha(p[j]) && j >= cmdmods[i].minlen
|
if (!ASCII_ISALPHA(p[j]) && j >= cmdmods[i].minlen
|
||||||
&& (p == cmd || cmdmods[i].has_count))
|
&& (p == cmd || cmdmods[i].has_count))
|
||||||
return j + (int)(p - cmd);
|
return j + (int)(p - cmd);
|
||||||
}
|
}
|
||||||
|
14
src/macros.h
14
src/macros.h
@@ -99,6 +99,11 @@
|
|||||||
# define MB_TOUPPER(c) TOUPPER_LOC(c)
|
# define MB_TOUPPER(c) TOUPPER_LOC(c)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Use our own isdigit() replacement, because on MS-Windows isdigit() returns
|
||||||
|
* non-zero for superscript 1. Also avoids that isdigit() crashes for numbers
|
||||||
|
* below 0 and above 255. */
|
||||||
|
#define VIM_ISDIGIT(c) ((unsigned)(c) - '0' < 10)
|
||||||
|
|
||||||
/* Like isalpha() but reject non-ASCII characters. Can't be used with a
|
/* Like isalpha() but reject non-ASCII characters. Can't be used with a
|
||||||
* special key (negative value). */
|
* special key (negative value). */
|
||||||
#ifdef EBCDIC
|
#ifdef EBCDIC
|
||||||
@@ -107,17 +112,12 @@
|
|||||||
# define ASCII_ISLOWER(c) islower(c)
|
# define ASCII_ISLOWER(c) islower(c)
|
||||||
# define ASCII_ISUPPER(c) isupper(c)
|
# define ASCII_ISUPPER(c) isupper(c)
|
||||||
#else
|
#else
|
||||||
# define ASCII_ISALPHA(c) ((c) < 0x7f && isalpha(c))
|
|
||||||
# define ASCII_ISALNUM(c) ((c) < 0x7f && isalnum(c))
|
|
||||||
# define ASCII_ISLOWER(c) ((unsigned)(c) - 'a' < 26)
|
# define ASCII_ISLOWER(c) ((unsigned)(c) - 'a' < 26)
|
||||||
# define ASCII_ISUPPER(c) ((unsigned)(c) - 'A' < 26)
|
# define ASCII_ISUPPER(c) ((unsigned)(c) - 'A' < 26)
|
||||||
|
# define ASCII_ISALPHA(c) (ASCII_ISUPPER(c) || ASCII_ISLOWER(c))
|
||||||
|
# define ASCII_ISALNUM(c) (ASCII_ISALPHA(c) || VIM_ISDIGIT(c))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Use our own isdigit() replacement, because on MS-Windows isdigit() returns
|
|
||||||
* non-zero for superscript 1. Also avoids that isdigit() crashes for numbers
|
|
||||||
* below 0 and above 255. */
|
|
||||||
#define VIM_ISDIGIT(c) ((unsigned)(c) - '0' < 10)
|
|
||||||
|
|
||||||
/* macro version of chartab().
|
/* macro version of chartab().
|
||||||
* Only works with values 0-255!
|
* Only works with values 0-255!
|
||||||
* Doesn't work for UTF-8 mode with chars >= 0x80. */
|
* Doesn't work for UTF-8 mode with chars >= 0x80. */
|
||||||
|
@@ -728,6 +728,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 */
|
||||||
|
/**/
|
||||||
|
1175,
|
||||||
/**/
|
/**/
|
||||||
1174,
|
1174,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user