summaryrefslogtreecommitdiff
path: root/src/macros.h
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2013-06-12 14:10:26 +0200
committerBram Moolenaar <Bram@vim.org>2013-06-12 14:10:26 +0200
commit0ea4a6b94b6f7a13ef5027b43c36bda0836b51af (patch)
tree27c05d8606028c9500525343abe7bdbfaad51584 /src/macros.h
parent60bf1f58d0edc45582fa065c3e0f68ae0de637ee (diff)
downloadvim-git-0ea4a6b94b6f7a13ef5027b43c36bda0836b51af.tar.gz
updated for version 7.3.1171v7.3.1171
Problem: Check for digits and ascii letters can be faster. Solution: Use a trick with one comparison. (Dominique Pelle)
Diffstat (limited to 'src/macros.h')
-rw-r--r--src/macros.h9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/macros.h b/src/macros.h
index 1737cfa54..2c305ce1d 100644
--- a/src/macros.h
+++ b/src/macros.h
@@ -109,15 +109,14 @@
#else
# define ASCII_ISALPHA(c) ((c) < 0x7f && isalpha(c))
# define ASCII_ISALNUM(c) ((c) < 0x7f && isalnum(c))
-# define ASCII_ISLOWER(c) ((c) < 0x7f && islower(c))
-# define ASCII_ISUPPER(c) ((c) < 0x7f && isupper(c))
+# define ASCII_ISLOWER(c) ((unsigned)(c) - 'a' < 26)
+# define ASCII_ISUPPER(c) ((unsigned)(c) - 'A' < 26)
#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. For complicated arguments and in/decrement use
- * vim_isdigit() instead. */
-#define VIM_ISDIGIT(c) ((c) >= '0' && (c) <= '9')
+ * below 0 and above 255. */
+#define VIM_ISDIGIT(c) ((unsigned)(c) - '0' < 10)
/* macro version of chartab().
* Only works with values 0-255!