summaryrefslogtreecommitdiff
path: root/ext/mbstring/php_unicode.h
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2017-07-20 11:48:52 +0200
committerNikita Popov <nikita.ppv@gmail.com>2017-07-20 13:58:40 +0200
commit79c26d597fd8245c30ee74faf05b8d6f9ece3fef (patch)
tree37e4bc0e989168b710b8ccbafde2ad3fc663155b /ext/mbstring/php_unicode.h
parenta3b42ea96bcf8e1574098a2f7a4a7f8d15f63b18 (diff)
downloadphp-git-79c26d597fd8245c30ee74faf05b8d6f9ece3fef.tar.gz
Optimize php_unicode_is_lower/upper for ASCII
Diffstat (limited to 'ext/mbstring/php_unicode.h')
-rw-r--r--ext/mbstring/php_unicode.h20
1 files changed, 18 insertions, 2 deletions
diff --git a/ext/mbstring/php_unicode.h b/ext/mbstring/php_unicode.h
index 3a6c75ce86..61415216c0 100644
--- a/ext/mbstring/php_unicode.h
+++ b/ext/mbstring/php_unicode.h
@@ -103,6 +103,24 @@ MBSTRING_API char *php_unicode_convert_case(
#define PHP_UNICODE_CASE_LOWER 1
#define PHP_UNICODE_CASE_TITLE 2
+/* Optimize the common ASCII case for lower/upper */
+
+static inline int php_unicode_is_lower(unsigned long code) {
+ if (code < 0x80) {
+ return code >= 0x61 && code <= 0x7A;
+ } else {
+ return php_unicode_is_prop1(code, UC_LL);
+ }
+}
+
+static inline int php_unicode_is_upper(unsigned long code) {
+ if (code < 0x80) {
+ return code >= 0x41 && code <= 0x5A;
+ } else {
+ return php_unicode_is_prop1(code, UC_LU);
+ }
+}
+
#define php_unicode_is_alpha(cc) php_unicode_is_prop(cc, UC_LU, UC_LL, UC_LM, UC_LO, UC_LT, -1)
#define php_unicode_is_digit(cc) php_unicode_is_prop1(cc, UC_ND)
#define php_unicode_is_alnum(cc) php_unicode_is_prop(cc, UC_LU, UC_LL, UC_LM, UC_LO, UC_LT, UC_ND, -1)
@@ -118,8 +136,6 @@ MBSTRING_API char *php_unicode_convert_case(
UC_LU, UC_LL, UC_LT, UC_LM, UC_LO, UC_PC, UC_PD, \
UC_PS, UC_PE, UC_PO, UC_SM, UC_SM, UC_SC, UC_SK, \
UC_SO, UC_ZS, UC_PI, UC_PF, -1)
-#define php_unicode_is_upper(cc) php_unicode_is_prop1(cc, UC_LU)
-#define php_unicode_is_lower(cc) php_unicode_is_prop1(cc, UC_LL)
#define php_unicode_is_title(cc) php_unicode_is_prop1(cc, UC_LT)
#define php_unicode_is_xdigit(cc) php_unicode_is_prop1(cc, UC_HD)