com php-src: Optimize php_unicode_is_lower/upper for ASCII: ext/mbstring/php_unicode.h
| From: | Nikita Popov | Date: | Thu, 20 Jul 2017 11:58:40 +0000 |
| Subject: | com php-src: Optimize php_unicode_is_lower/upper for ASCII: ext/mbstring/php_unicode.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-98655@lists.php.net to get a copy of this message | ||
Commit: 79c26d597fd8245c30ee74faf05b8d6f9ece3fef
Author: Nikita Popov <nikita.ppv@gmail.com> Thu, 20 Jul 2017 11:48:52 +0200
Parents: a3b42ea96bcf8e1574098a2f7a4a7f8d15f63b18
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=79c26d597fd8245c30ee74faf05b8d6f9ece3fef
Log:
Optimize php_unicode_is_lower/upper for ASCII
Changed paths:
M ext/mbstring/php_unicode.h
Diff:
diff --git a/ext/mbstring/php_unicode.h b/ext/mbstring/php_unicode.h
index 3a6c75c..6141521 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)