Skip to content

Commit

Permalink
Use zend_hash_find() instead of zend_hash_exists()
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Sep 19, 2018
1 parent 2a54867 commit 6beaa9f
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 50 deletions.
20 changes: 10 additions & 10 deletions Zend/zend_vm_def.h
Expand Up @@ -7963,37 +7963,37 @@ ZEND_VM_COLD_CONSTCONST_HANDLER(189, ZEND_IN_ARRAY, CONST|TMP|VAR|CV, CONST, NUM
zend_free_op free_op1;
zval *op1;
HashTable *ht = Z_ARRVAL_P(RT_CONSTANT(opline, opline->op2));
int result;
zval *result;

SAVE_OPLINE();
op1 = GET_OP1_ZVAL_PTR_DEREF(BP_VAR_R);
if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) {
result = zend_hash_exists(ht, Z_STR_P(op1));
result = zend_hash_find_ex(ht, Z_STR_P(op1), OP1_TYPE == IS_CONST);
} else if (opline->extended_value) {
if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
result = zend_hash_index_exists(ht, Z_LVAL_P(op1));
result = zend_hash_index_find(ht, Z_LVAL_P(op1));
} else {
result = 0;
result = NULL;
}
} else if (Z_TYPE_P(op1) <= IS_FALSE) {
result = zend_hash_exists(ht, ZSTR_EMPTY_ALLOC());
result = zend_hash_find_ex(ht, ZSTR_EMPTY_ALLOC(), 1);
} else {
zend_string *key;
zval key_tmp, result_tmp;
zval key_tmp, result_tmp, *val;

result = 0;
ZEND_HASH_FOREACH_STR_KEY(ht, key) {
result = NULL;
ZEND_HASH_FOREACH_STR_KEY_VAL(ht, key, val) {
ZVAL_STR(&key_tmp, key);
compare_function(&result_tmp, op1, &key_tmp);
if (Z_LVAL(result_tmp) == 0) {
result = 1;
result = val;
break;
}
} ZEND_HASH_FOREACH_END();
}
FREE_OP1();
ZEND_VM_SMART_BRANCH(result, 1);
ZVAL_BOOL(EX_VAR(opline->result.var), result);
ZVAL_BOOL(EX_VAR(opline->result.var), result != NULL);
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}

Expand Down
80 changes: 40 additions & 40 deletions Zend/zend_vm_execute.h
Expand Up @@ -6055,37 +6055,37 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IN_ARRAY_SPEC_CON

zval *op1;
HashTable *ht = Z_ARRVAL_P(RT_CONSTANT(opline, opline->op2));
int result;
zval *result;

SAVE_OPLINE();
op1 = RT_CONSTANT(opline, opline->op1);
if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) {
result = zend_hash_exists(ht, Z_STR_P(op1));
result = zend_hash_find_ex(ht, Z_STR_P(op1), IS_CONST == IS_CONST);
} else if (opline->extended_value) {
if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
result = zend_hash_index_exists(ht, Z_LVAL_P(op1));
result = zend_hash_index_find(ht, Z_LVAL_P(op1));
} else {
result = 0;
result = NULL;
}
} else if (Z_TYPE_P(op1) <= IS_FALSE) {
result = zend_hash_exists(ht, ZSTR_EMPTY_ALLOC());
result = zend_hash_find_ex(ht, ZSTR_EMPTY_ALLOC(), 1);
} else {
zend_string *key;
zval key_tmp, result_tmp;
zval key_tmp, result_tmp, *val;

result = 0;
ZEND_HASH_FOREACH_STR_KEY(ht, key) {
result = NULL;
ZEND_HASH_FOREACH_STR_KEY_VAL(ht, key, val) {
ZVAL_STR(&key_tmp, key);
compare_function(&result_tmp, op1, &key_tmp);
if (Z_LVAL(result_tmp) == 0) {
result = 1;
result = val;
break;
}
} ZEND_HASH_FOREACH_END();
}

ZEND_VM_SMART_BRANCH(result, 1);
ZVAL_BOOL(EX_VAR(opline->result.var), result);
ZVAL_BOOL(EX_VAR(opline->result.var), result != NULL);
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}

Expand Down Expand Up @@ -18903,37 +18903,37 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IN_ARRAY_SPEC_TMP_CONST_HANDLE
zend_free_op free_op1;
zval *op1;
HashTable *ht = Z_ARRVAL_P(RT_CONSTANT(opline, opline->op2));
int result;
zval *result;

SAVE_OPLINE();
op1 = _get_zval_ptr_tmp(opline->op1.var, &free_op1 EXECUTE_DATA_CC);
if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) {
result = zend_hash_exists(ht, Z_STR_P(op1));
result = zend_hash_find_ex(ht, Z_STR_P(op1), IS_TMP_VAR == IS_CONST);
} else if (opline->extended_value) {
if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
result = zend_hash_index_exists(ht, Z_LVAL_P(op1));
result = zend_hash_index_find(ht, Z_LVAL_P(op1));
} else {
result = 0;
result = NULL;
}
} else if (Z_TYPE_P(op1) <= IS_FALSE) {
result = zend_hash_exists(ht, ZSTR_EMPTY_ALLOC());
result = zend_hash_find_ex(ht, ZSTR_EMPTY_ALLOC(), 1);
} else {
zend_string *key;
zval key_tmp, result_tmp;
zval key_tmp, result_tmp, *val;

result = 0;
ZEND_HASH_FOREACH_STR_KEY(ht, key) {
result = NULL;
ZEND_HASH_FOREACH_STR_KEY_VAL(ht, key, val) {
ZVAL_STR(&key_tmp, key);
compare_function(&result_tmp, op1, &key_tmp);
if (Z_LVAL(result_tmp) == 0) {
result = 1;
result = val;
break;
}
} ZEND_HASH_FOREACH_END();
}
zval_ptr_dtor_nogc(free_op1);
ZEND_VM_SMART_BRANCH(result, 1);
ZVAL_BOOL(EX_VAR(opline->result.var), result);
ZVAL_BOOL(EX_VAR(opline->result.var), result != NULL);
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}

Expand Down Expand Up @@ -24217,37 +24217,37 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IN_ARRAY_SPEC_VAR_CONST_HANDLE
zend_free_op free_op1;
zval *op1;
HashTable *ht = Z_ARRVAL_P(RT_CONSTANT(opline, opline->op2));
int result;
zval *result;

SAVE_OPLINE();
op1 = _get_zval_ptr_var_deref(opline->op1.var, &free_op1 EXECUTE_DATA_CC);
if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) {
result = zend_hash_exists(ht, Z_STR_P(op1));
result = zend_hash_find_ex(ht, Z_STR_P(op1), IS_VAR == IS_CONST);
} else if (opline->extended_value) {
if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
result = zend_hash_index_exists(ht, Z_LVAL_P(op1));
result = zend_hash_index_find(ht, Z_LVAL_P(op1));
} else {
result = 0;
result = NULL;
}
} else if (Z_TYPE_P(op1) <= IS_FALSE) {
result = zend_hash_exists(ht, ZSTR_EMPTY_ALLOC());
result = zend_hash_find_ex(ht, ZSTR_EMPTY_ALLOC(), 1);
} else {
zend_string *key;
zval key_tmp, result_tmp;
zval key_tmp, result_tmp, *val;

result = 0;
ZEND_HASH_FOREACH_STR_KEY(ht, key) {
result = NULL;
ZEND_HASH_FOREACH_STR_KEY_VAL(ht, key, val) {
ZVAL_STR(&key_tmp, key);
compare_function(&result_tmp, op1, &key_tmp);
if (Z_LVAL(result_tmp) == 0) {
result = 1;
result = val;
break;
}
} ZEND_HASH_FOREACH_END();
}
zval_ptr_dtor_nogc(free_op1);
ZEND_VM_SMART_BRANCH(result, 1);
ZVAL_BOOL(EX_VAR(opline->result.var), result);
ZVAL_BOOL(EX_VAR(opline->result.var), result != NULL);
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}

Expand Down Expand Up @@ -41899,37 +41899,37 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IN_ARRAY_SPEC_CV_CONST_HANDLER

zval *op1;
HashTable *ht = Z_ARRVAL_P(RT_CONSTANT(opline, opline->op2));
int result;
zval *result;

SAVE_OPLINE();
op1 = _get_zval_ptr_cv_deref_BP_VAR_R(opline->op1.var EXECUTE_DATA_CC);
if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) {
result = zend_hash_exists(ht, Z_STR_P(op1));
result = zend_hash_find_ex(ht, Z_STR_P(op1), IS_CV == IS_CONST);
} else if (opline->extended_value) {
if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
result = zend_hash_index_exists(ht, Z_LVAL_P(op1));
result = zend_hash_index_find(ht, Z_LVAL_P(op1));
} else {
result = 0;
result = NULL;
}
} else if (Z_TYPE_P(op1) <= IS_FALSE) {
result = zend_hash_exists(ht, ZSTR_EMPTY_ALLOC());
result = zend_hash_find_ex(ht, ZSTR_EMPTY_ALLOC(), 1);
} else {
zend_string *key;
zval key_tmp, result_tmp;
zval key_tmp, result_tmp, *val;

result = 0;
ZEND_HASH_FOREACH_STR_KEY(ht, key) {
result = NULL;
ZEND_HASH_FOREACH_STR_KEY_VAL(ht, key, val) {
ZVAL_STR(&key_tmp, key);
compare_function(&result_tmp, op1, &key_tmp);
if (Z_LVAL(result_tmp) == 0) {
result = 1;
result = val;
break;
}
} ZEND_HASH_FOREACH_END();
}

ZEND_VM_SMART_BRANCH(result, 1);
ZVAL_BOOL(EX_VAR(opline->result.var), result);
ZVAL_BOOL(EX_VAR(opline->result.var), result != NULL);
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}

Expand Down

0 comments on commit 6beaa9f

Please sign in to comment.