com php-src: Simplfy zend_is_true: Zend/zend_operator s.h
| From: | Xinchen Hui | Date: | Thu, 10 Sep 2015 08:13:22 +0000 |
| Subject: | com php-src: Simplfy zend_is_true: Zend/zend_operator s.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-88986@lists.php.net to get a copy of this message | ||
Commit: 213b49620d24ebebe3cf19787ee6e3448d27d046
Author: Xinchen Hui <laruence@gmail.com> Thu, 10 Sep 2015 16:13:22 +0800
Parents: f3e8675d380af8c2fe632b9133ddcc7b1a304f49
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=213b49620d24ebebe3cf19787ee6e3448d27d046
Log:
Simplfy zend_is_true
Changed paths:
M Zend/zend_operators.h
Diff:
diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h
index 7cb3ee1..f8c155d 100644
--- a/Zend/zend_operators.h
+++ b/Zend/zend_operators.h
@@ -282,47 +282,46 @@ ZEND_API int ZEND_FASTCALL zend_object_is_true(zval *op);
static zend_always_inline int i_zend_is_true(zval *op)
{
- int result;
+ int result = 0;
again:
switch (Z_TYPE_P(op)) {
- case IS_UNDEF:
- case IS_NULL:
- case IS_FALSE:
- result = 0;
- break;
case IS_TRUE:
result = 1;
break;
case IS_LONG:
- result = (Z_LVAL_P(op)?1:0);
- break;
- case IS_RESOURCE:
- result = (Z_RES_HANDLE_P(op)?1:0);
+ if (Z_LVAL_P(op)) {
+ result = 1;
+ }
break;
case IS_DOUBLE:
- result = (Z_DVAL_P(op) ? 1 : 0);
+ if (Z_DVAL_P(op)) {
+ result = 1;
+ }
break;
case IS_STRING:
- if (Z_STRLEN_P(op) == 0
- || (Z_STRLEN_P(op)==1 && Z_STRVAL_P(op)[0]=='0')) {
- result = 0;
- } else {
+ if (Z_STRLEN_P(op) > 1 || (Z_STRLEN_P(op) && Z_STRVAL_P(op)[0] != '0')) {
result = 1;
}
break;
case IS_ARRAY:
- result = (zend_hash_num_elements(Z_ARRVAL_P(op))?1:0);
+ if (zend_hash_num_elements(Z_ARRVAL_P(op))) {
+ result = 1;
+ }
break;
case IS_OBJECT:
result = zend_object_is_true(op);
break;
+ case IS_RESOURCE:
+ if (EXPECTED(Z_RES_HANDLE_P(op))) {
+ result = 1;
+ }
+ break;
case IS_REFERENCE:
op = Z_REFVAL_P(op);
goto again;
break;
default:
- result = 0;
break;
}
return result;