Skip to content

Commit 47ee470

Browse files
committed
Make use of direct returns in some places
1 parent 0856714 commit 47ee470

File tree

4 files changed

+21
-32
lines changed

4 files changed

+21
-32
lines changed

Zend/zend_closures.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,8 @@ ZEND_METHOD(Closure, __invoke) /* {{{ */
5959
} else if (call_user_function_ex(CG(function_table), NULL, this_ptr, &closure_result_ptr, ZEND_NUM_ARGS(), arguments, 1, NULL TSRMLS_CC) == FAILURE) {
6060
RETVAL_FALSE;
6161
} else if (closure_result_ptr) {
62-
if (Z_ISREF_P(closure_result_ptr) && return_value_ptr) {
63-
if (return_value) {
64-
zval_ptr_dtor(&return_value);
65-
}
66-
*return_value_ptr = closure_result_ptr;
67-
} else {
68-
RETVAL_ZVAL(closure_result_ptr, 1, 1);
69-
}
62+
zval_ptr_dtor(&return_value);
63+
*return_value_ptr = closure_result_ptr;
7064
}
7165
efree(arguments);
7266

Zend/zend_generators.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ ZEND_METHOD(Generator, current)
430430
zend_generator_ensure_initialized(generator TSRMLS_CC);
431431

432432
if (generator->value) {
433-
RETURN_ZVAL(generator->value, 1, 0);
433+
RETURN_ZVAL_FAST(generator->value);
434434
}
435435
}
436436
/* }}} */
@@ -450,7 +450,7 @@ ZEND_METHOD(Generator, key)
450450
zend_generator_ensure_initialized(generator TSRMLS_CC);
451451

452452
if (generator->key) {
453-
RETURN_ZVAL(generator->key, 1, 0);
453+
RETURN_ZVAL_FAST(generator->key);
454454
}
455455
}
456456
/* }}} */
@@ -499,7 +499,7 @@ ZEND_METHOD(Generator, send)
499499
zend_generator_resume(generator TSRMLS_CC);
500500

501501
if (generator->value) {
502-
RETURN_ZVAL(generator->value, 1, 0);
502+
RETURN_ZVAL_FAST(generator->value);
503503
}
504504
}
505505
/* }}} */
@@ -532,7 +532,7 @@ ZEND_METHOD(Generator, throw)
532532
zend_generator_resume(generator TSRMLS_CC);
533533

534534
if (generator->value) {
535-
RETURN_ZVAL(generator->value, 1, 0);
535+
RETURN_ZVAL_FAST(generator->value);
536536
}
537537
} else {
538538
/* If the generator is already closed throw the exception in the

Zend/zend_object_handlers.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -896,11 +896,8 @@ ZEND_API void zend_std_call_user_call(INTERNAL_FUNCTION_PARAMETERS) /* {{{ */
896896
zend_call_method_with_2_params(&this_ptr, ce, &ce->__call, ZEND_CALL_FUNC_NAME, &method_result_ptr, method_name_ptr, method_args_ptr);
897897

898898
if (method_result_ptr) {
899-
if (Z_ISREF_P(method_result_ptr) || Z_REFCOUNT_P(method_result_ptr) > 1) {
900-
RETVAL_ZVAL(method_result_ptr, 1, 1);
901-
} else {
902-
RETVAL_ZVAL(method_result_ptr, 0, 1);
903-
}
899+
RETVAL_ZVAL_FAST(method_result_ptr);
900+
zval_ptr_dtor(&method_result_ptr);
904901
}
905902

906903
/* now destruct all auxiliaries */
@@ -1113,11 +1110,8 @@ ZEND_API void zend_std_callstatic_user_call(INTERNAL_FUNCTION_PARAMETERS) /* {{{
11131110
zend_call_method_with_2_params(NULL, ce, &ce->__callstatic, ZEND_CALLSTATIC_FUNC_NAME, &method_result_ptr, method_name_ptr, method_args_ptr);
11141111

11151112
if (method_result_ptr) {
1116-
if (Z_ISREF_P(method_result_ptr) || Z_REFCOUNT_P(method_result_ptr) > 1) {
1117-
RETVAL_ZVAL(method_result_ptr, 1, 1);
1118-
} else {
1119-
RETVAL_ZVAL(method_result_ptr, 0, 1);
1120-
}
1113+
RETVAL_ZVAL_FAST(method_result_ptr);
1114+
zval_ptr_dtor(&method_result_ptr);
11211115
}
11221116

11231117
/* now destruct all auxiliaries */

ext/standard/array.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ PHP_FUNCTION(end)
830830
RETURN_FALSE;
831831
}
832832

833-
RETURN_ZVAL(*entry, 1, 0);
833+
RETURN_ZVAL_FAST(*entry);
834834
}
835835
}
836836
/* }}} */
@@ -853,7 +853,7 @@ PHP_FUNCTION(prev)
853853
RETURN_FALSE;
854854
}
855855

856-
RETURN_ZVAL(*entry, 1, 0);
856+
RETURN_ZVAL_FAST(*entry);
857857
}
858858
}
859859
/* }}} */
@@ -876,7 +876,7 @@ PHP_FUNCTION(next)
876876
RETURN_FALSE;
877877
}
878878

879-
RETURN_ZVAL(*entry, 1, 0);
879+
RETURN_ZVAL_FAST(*entry);
880880
}
881881
}
882882
/* }}} */
@@ -899,7 +899,7 @@ PHP_FUNCTION(reset)
899899
RETURN_FALSE;
900900
}
901901

902-
RETURN_ZVAL(*entry, 1, 0);
902+
RETURN_ZVAL_FAST(*entry);
903903
}
904904
}
905905
/* }}} */
@@ -918,7 +918,8 @@ PHP_FUNCTION(current)
918918
if (zend_hash_get_current_data(array, (void **) &entry) == FAILURE) {
919919
RETURN_FALSE;
920920
}
921-
RETURN_ZVAL(*entry, 1, 0);
921+
922+
RETURN_ZVAL_FAST(*entry);
922923
}
923924
/* }}} */
924925

@@ -958,7 +959,7 @@ PHP_FUNCTION(min)
958959
RETVAL_NULL();
959960
} else {
960961
if (zend_hash_minmax(Z_ARRVAL_PP(args[0]), php_array_data_compare, 0, (void **) &result TSRMLS_CC) == SUCCESS) {
961-
RETVAL_ZVAL(*result, 1, 0);
962+
RETVAL_ZVAL_FAST(*result);
962963
} else {
963964
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Array must contain at least one element");
964965
RETVAL_FALSE;
@@ -978,7 +979,7 @@ PHP_FUNCTION(min)
978979
}
979980
}
980981

981-
RETVAL_ZVAL(*min, 1, 0);
982+
RETVAL_ZVAL_FAST(*min);
982983
}
983984

984985
if (args) {
@@ -1009,7 +1010,7 @@ PHP_FUNCTION(max)
10091010
RETVAL_NULL();
10101011
} else {
10111012
if (zend_hash_minmax(Z_ARRVAL_PP(args[0]), php_array_data_compare, 1, (void **) &result TSRMLS_CC) == SUCCESS) {
1012-
RETVAL_ZVAL(*result, 1, 0);
1013+
RETVAL_ZVAL_FAST(*result);
10131014
} else {
10141015
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Array must contain at least one element");
10151016
RETVAL_FALSE;
@@ -1029,7 +1030,7 @@ PHP_FUNCTION(max)
10291030
}
10301031
}
10311032

1032-
RETVAL_ZVAL(*max, 1, 0);
1033+
RETVAL_ZVAL_FAST(*max);
10331034
}
10341035

10351036
if (args) {
@@ -1955,7 +1956,7 @@ static void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int off_the_end)
19551956
zend_hash_internal_pointer_reset(Z_ARRVAL_P(stack));
19561957
}
19571958
zend_hash_get_current_data(Z_ARRVAL_P(stack), (void **)&val);
1958-
RETVAL_ZVAL(*val, 1, 0);
1959+
RETVAL_ZVAL_FAST(*val);
19591960

19601961
/* Delete the first or last value */
19611962
zend_hash_get_current_key_ex(Z_ARRVAL_P(stack), &key, &key_len, &index, 0, NULL);

0 commit comments

Comments
 (0)