summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2018-05-08 11:58:17 +0300
committerDmitry Stogov <dmitry@zend.com>2018-05-08 11:58:17 +0300
commit4ad9cf460595efd1151faec0780b6ae5a4e0bc57 (patch)
tree21ce3f1d510267c812e54470a5addcb689de300f /ext
parentdc796b04c1193e0ca5def1239c5bd2bd93d5af09 (diff)
downloadphp-git-4ad9cf460595efd1151faec0780b6ae5a4e0bc57.tar.gz
Bit test optimization
Diffstat (limited to 'ext')
-rw-r--r--ext/json/json_encoder.c2
-rw-r--r--ext/mysqlnd/mysqlnd_result.c4
-rw-r--r--ext/standard/array.c12
3 files changed, 9 insertions, 9 deletions
diff --git a/ext/json/json_encoder.c b/ext/json/json_encoder.c
index 3ec12b8968..f28bfbd4e4 100644
--- a/ext/json/json_encoder.c
+++ b/ext/json/json_encoder.c
@@ -350,7 +350,7 @@ static int php_json_escape_string(
0xffffffff, 0x500080c4, 0x10000000, 0x00000000};
pos++;
- if (EXPECTED(!((charmap[us >> 5] >> (us & 0x1f)) & 1))) {
+ if (EXPECTED(!ZEND_BIT_TEST(charmap, us))) {
smart_str_appendc(buf, (unsigned char) us);
} else {
switch (us) {
diff --git a/ext/mysqlnd/mysqlnd_result.c b/ext/mysqlnd/mysqlnd_result.c
index 653197e302..b436f23ac0 100644
--- a/ext/mysqlnd/mysqlnd_result.c
+++ b/ext/mysqlnd/mysqlnd_result.c
@@ -108,7 +108,7 @@ MYSQLND_METHOD(mysqlnd_result_buffered_c, initialize_result_set_rest)(MYSQLND_RE
for (i = 0; i < result->row_count; i++) {
/* (i / 8) & the_bit_for_i*/
- if ((initialized[i >> 3] >> (i & 7)) & 1) {
+ if (ZEND_BIT_TEST(initialized, i)) {
continue;
}
@@ -1151,7 +1151,7 @@ MYSQLND_METHOD(mysqlnd_result_buffered_c, fetch_row)(MYSQLND_RES * result, void
if (rc != PASS) {
DBG_RETURN(FAIL);
}
- if (!((set->initialized[set->current_row >> 3] >> (set->current_row & 7)) & 1)) {
+ if (!ZEND_BIT_TEST(set->initialized, set->current_row)) {
set->initialized[set->current_row >> 3] |= (1 << (set->current_row & 7)); /* mark initialized */
++set->initialized_rows;
diff --git a/ext/standard/array.c b/ext/standard/array.c
index cfd29378a0..7621b0616a 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -1660,14 +1660,14 @@ static zend_always_inline int php_valid_var_name(const char *var_name, size_t va
{
#if 1
/* first 256 bits for first character, and second 256 bits for the next */
- static const uint32_t charset[16] = {
+ static const uint32_t charset[8] = {
/* 31 0 63 32 95 64 127 96 */
0x00000000, 0x00000000, 0x87fffffe, 0x07fffffe,
- 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff};
+ static const uint32_t charset2[8] = {
/* 31 0 63 32 95 64 127 96 */
0x00000000, 0x03ff0000, 0x87fffffe, 0x07fffffe,
- 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
- };
+ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff};
#endif
size_t i;
uint32_t ch;
@@ -1679,7 +1679,7 @@ static zend_always_inline int php_valid_var_name(const char *var_name, size_t va
/* These are allowed as first char: [a-zA-Z_\x7f-\xff] */
ch = (uint32_t)((unsigned char *)var_name)[0];
#if 1
- if (UNEXPECTED(!((charset[ch >> 5] >> (ch & 0x1f)) & 1))) {
+ if (UNEXPECTED(!ZEND_BIT_TEST(charset, ch))) {
#else
if (var_name[0] != '_' &&
(ch < 65 /* A */ || /* Z */ ch > 90) &&
@@ -1696,7 +1696,7 @@ static zend_always_inline int php_valid_var_name(const char *var_name, size_t va
do {
ch = (uint32_t)((unsigned char *)var_name)[i];
#if 1
- if (UNEXPECTED(!((charset[8 + (ch >> 5)] >> (ch & 0x1f)) & 1))) {
+ if (UNEXPECTED(!ZEND_BIT_TEST(charset2, ch))) {
#else
if (var_name[i] != '_' &&
(ch < 48 /* 0 */ || /* 9 */ ch > 57) &&