Skip to content

Commit 8f4f1de

Browse files
committed
Convert zend_parse_parameters_none() to fast ZPP
I've done the conversion in those extensions where fast ZPP is predominant.
1 parent b7d2882 commit 8f4f1de

File tree

9 files changed

+60
-130
lines changed

9 files changed

+60
-130
lines changed

Zend/zend_builtin_functions.c

Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,7 @@ int zend_startup_builtin_functions(void) /* {{{ */
190190
Get the version of the Zend Engine */
191191
ZEND_FUNCTION(zend_version)
192192
{
193-
if (zend_parse_parameters_none() == FAILURE) {
194-
RETURN_THROWS();
195-
}
193+
ZEND_PARSE_PARAMETERS_NONE();
196194

197195
RETURN_STRINGL(ZEND_VERSION, sizeof(ZEND_VERSION)-1);
198196
}
@@ -203,9 +201,7 @@ ZEND_FUNCTION(zend_version)
203201
Returns number of freed bytes */
204202
ZEND_FUNCTION(gc_mem_caches)
205203
{
206-
if (zend_parse_parameters_none() == FAILURE) {
207-
RETURN_THROWS();
208-
}
204+
ZEND_PARSE_PARAMETERS_NONE();
209205

210206
RETURN_LONG(zend_mm_gc(zend_mm_get_heap()));
211207
}
@@ -216,9 +212,7 @@ ZEND_FUNCTION(gc_mem_caches)
216212
Returns number of freed zvals */
217213
ZEND_FUNCTION(gc_collect_cycles)
218214
{
219-
if (zend_parse_parameters_none() == FAILURE) {
220-
RETURN_THROWS();
221-
}
215+
ZEND_PARSE_PARAMETERS_NONE();
222216

223217
RETURN_LONG(gc_collect_cycles());
224218
}
@@ -228,9 +222,7 @@ ZEND_FUNCTION(gc_collect_cycles)
228222
Returns status of the circular reference collector */
229223
ZEND_FUNCTION(gc_enabled)
230224
{
231-
if (zend_parse_parameters_none() == FAILURE) {
232-
RETURN_THROWS();
233-
}
225+
ZEND_PARSE_PARAMETERS_NONE();
234226

235227
RETURN_BOOL(gc_enabled());
236228
}
@@ -242,9 +234,7 @@ ZEND_FUNCTION(gc_enable)
242234
{
243235
zend_string *key;
244236

245-
if (zend_parse_parameters_none() == FAILURE) {
246-
RETURN_THROWS();
247-
}
237+
ZEND_PARSE_PARAMETERS_NONE();
248238

249239
key = zend_string_init("zend.enable_gc", sizeof("zend.enable_gc")-1, 0);
250240
zend_alter_ini_entry_chars(key, "1", sizeof("1")-1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME);
@@ -258,9 +248,7 @@ ZEND_FUNCTION(gc_disable)
258248
{
259249
zend_string *key;
260250

261-
if (zend_parse_parameters_none() == FAILURE) {
262-
RETURN_THROWS();
263-
}
251+
ZEND_PARSE_PARAMETERS_NONE();
264252

265253
key = zend_string_init("zend.enable_gc", sizeof("zend.enable_gc")-1, 0);
266254
zend_alter_ini_entry_chars(key, "0", sizeof("0")-1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME);
@@ -274,9 +262,7 @@ ZEND_FUNCTION(gc_status)
274262
{
275263
zend_gc_status status;
276264

277-
if (zend_parse_parameters_none() == FAILURE) {
278-
RETURN_THROWS();
279-
}
265+
ZEND_PARSE_PARAMETERS_NONE();
280266

281267
zend_gc_get_status(&status);
282268

@@ -295,9 +281,7 @@ ZEND_FUNCTION(func_num_args)
295281
{
296282
zend_execute_data *ex = EX(prev_execute_data);
297283

298-
if (zend_parse_parameters_none() == FAILURE) {
299-
RETURN_THROWS();
300-
}
284+
ZEND_PARSE_PARAMETERS_NONE();
301285

302286
if (ZEND_CALL_INFO(ex) & ZEND_CALL_CODE) {
303287
zend_error(E_WARNING, "func_num_args(): Called from the global scope - no function context");
@@ -759,9 +743,7 @@ ZEND_FUNCTION(get_called_class)
759743
{
760744
zend_class_entry *called_scope;
761745

762-
if (zend_parse_parameters_none() == FAILURE) {
763-
RETURN_THROWS();
764-
}
746+
ZEND_PARSE_PARAMETERS_NONE();
765747

766748
called_scope = zend_get_called_scope(execute_data);
767749
if (called_scope) {
@@ -1352,9 +1334,7 @@ ZEND_FUNCTION(get_included_files)
13521334
{
13531335
zend_string *entry;
13541336

1355-
if (zend_parse_parameters_none() == FAILURE) {
1356-
RETURN_THROWS();
1357-
}
1337+
ZEND_PARSE_PARAMETERS_NONE();
13581338

13591339
array_init(return_value);
13601340
ZEND_HASH_FOREACH_STR_KEY(&EG(included_files), entry) {
@@ -1436,9 +1416,7 @@ ZEND_FUNCTION(set_error_handler)
14361416
Restores the previously defined error handler function */
14371417
ZEND_FUNCTION(restore_error_handler)
14381418
{
1439-
if (zend_parse_parameters_none() == FAILURE) {
1440-
RETURN_THROWS();
1441-
}
1419+
ZEND_PARSE_PARAMETERS_NONE();
14421420

14431421
if (Z_TYPE(EG(user_error_handler)) != IS_UNDEF) {
14441422
zval zeh;
@@ -1501,9 +1479,7 @@ ZEND_FUNCTION(set_exception_handler)
15011479
Restores the previously defined exception handler function */
15021480
ZEND_FUNCTION(restore_exception_handler)
15031481
{
1504-
if (zend_parse_parameters_none() == FAILURE) {
1505-
RETURN_THROWS();
1506-
}
1482+
ZEND_PARSE_PARAMETERS_NONE();
15071483

15081484
if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) {
15091485
zval_ptr_dtor(&EG(user_exception_handler));
@@ -1534,9 +1510,7 @@ static inline void get_declared_class_impl(INTERNAL_FUNCTION_PARAMETERS, int fla
15341510
zend_string *key;
15351511
zend_class_entry *ce;
15361512

1537-
if (zend_parse_parameters_none() == FAILURE) {
1538-
RETURN_THROWS();
1539-
}
1513+
ZEND_PARSE_PARAMETERS_NONE();
15401514

15411515
array_init(return_value);
15421516
ZEND_HASH_FOREACH_STR_KEY_PTR(EG(class_table), key, ce) {

Zend/zend_exceptions.c

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -391,11 +391,6 @@ ZEND_METHOD(error_exception, __construct)
391391
}
392392
/* }}} */
393393

394-
#define DEFAULT_0_PARAMS \
395-
if (zend_parse_parameters_none() == FAILURE) { \
396-
return; \
397-
}
398-
399394
#define GET_PROPERTY(object, id) \
400395
zend_read_property_ex(i_get_exception_base(object), (object), ZSTR_KNOWN(id), 0, &rv)
401396
#define GET_PROPERTY_SILENT(object, id) \
@@ -407,7 +402,7 @@ ZEND_METHOD(exception, getFile)
407402
{
408403
zval *prop, rv;
409404

410-
DEFAULT_0_PARAMS;
405+
ZEND_PARSE_PARAMETERS_NONE();
411406

412407
prop = GET_PROPERTY(ZEND_THIS, ZEND_STR_FILE);
413408
ZVAL_DEREF(prop);
@@ -421,7 +416,7 @@ ZEND_METHOD(exception, getLine)
421416
{
422417
zval *prop, rv;
423418

424-
DEFAULT_0_PARAMS;
419+
ZEND_PARSE_PARAMETERS_NONE();
425420

426421
prop = GET_PROPERTY(ZEND_THIS, ZEND_STR_LINE);
427422
ZVAL_DEREF(prop);
@@ -435,7 +430,7 @@ ZEND_METHOD(exception, getMessage)
435430
{
436431
zval *prop, rv;
437432

438-
DEFAULT_0_PARAMS;
433+
ZEND_PARSE_PARAMETERS_NONE();
439434

440435
prop = GET_PROPERTY(ZEND_THIS, ZEND_STR_MESSAGE);
441436
ZVAL_DEREF(prop);
@@ -449,7 +444,7 @@ ZEND_METHOD(exception, getCode)
449444
{
450445
zval *prop, rv;
451446

452-
DEFAULT_0_PARAMS;
447+
ZEND_PARSE_PARAMETERS_NONE();
453448

454449
prop = GET_PROPERTY(ZEND_THIS, ZEND_STR_CODE);
455450
ZVAL_DEREF(prop);
@@ -463,7 +458,7 @@ ZEND_METHOD(exception, getTrace)
463458
{
464459
zval *prop, rv;
465460

466-
DEFAULT_0_PARAMS;
461+
ZEND_PARSE_PARAMETERS_NONE();
467462

468463
prop = GET_PROPERTY(ZEND_THIS, ZEND_STR_TRACE);
469464
ZVAL_DEREF(prop);
@@ -477,7 +472,7 @@ ZEND_METHOD(error_exception, getSeverity)
477472
{
478473
zval *prop, rv;
479474

480-
DEFAULT_0_PARAMS;
475+
ZEND_PARSE_PARAMETERS_NONE();
481476

482477
prop = GET_PROPERTY(ZEND_THIS, ZEND_STR_SEVERITY);
483478
ZVAL_DEREF(prop);
@@ -625,7 +620,7 @@ ZEND_METHOD(exception, getTraceAsString)
625620
smart_str str = {0};
626621
uint32_t num = 0;
627622

628-
DEFAULT_0_PARAMS;
623+
ZEND_PARSE_PARAMETERS_NONE();
629624

630625
object = ZEND_THIS;
631626
base_ce = i_get_exception_base(object);
@@ -659,7 +654,7 @@ ZEND_METHOD(exception, getPrevious)
659654
{
660655
zval rv;
661656

662-
DEFAULT_0_PARAMS;
657+
ZEND_PARSE_PARAMETERS_NONE();
663658

664659
ZVAL_COPY(return_value, GET_PROPERTY_SILENT(ZEND_THIS, ZEND_STR_PREVIOUS));
665660
} /* }}} */
@@ -675,7 +670,7 @@ ZEND_METHOD(exception, __toString)
675670
zval rv, tmp;
676671
zend_string *fname;
677672

678-
DEFAULT_0_PARAMS;
673+
ZEND_PARSE_PARAMETERS_NONE();
679674

680675
str = ZSTR_EMPTY_ALLOC();
681676

Zend/zend_generators.c

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -895,9 +895,7 @@ ZEND_METHOD(Generator, rewind)
895895
{
896896
zend_generator *generator;
897897

898-
if (zend_parse_parameters_none() == FAILURE) {
899-
RETURN_THROWS();
900-
}
898+
ZEND_PARSE_PARAMETERS_NONE();
901899

902900
generator = (zend_generator *) Z_OBJ_P(ZEND_THIS);
903901

@@ -911,9 +909,7 @@ ZEND_METHOD(Generator, valid)
911909
{
912910
zend_generator *generator;
913911

914-
if (zend_parse_parameters_none() == FAILURE) {
915-
RETURN_THROWS();
916-
}
912+
ZEND_PARSE_PARAMETERS_NONE();
917913

918914
generator = (zend_generator *) Z_OBJ_P(ZEND_THIS);
919915

@@ -931,9 +927,7 @@ ZEND_METHOD(Generator, current)
931927
{
932928
zend_generator *generator, *root;
933929

934-
if (zend_parse_parameters_none() == FAILURE) {
935-
RETURN_THROWS();
936-
}
930+
ZEND_PARSE_PARAMETERS_NONE();
937931

938932
generator = (zend_generator *) Z_OBJ_P(ZEND_THIS);
939933

@@ -954,9 +948,7 @@ ZEND_METHOD(Generator, key)
954948
{
955949
zend_generator *generator, *root;
956950

957-
if (zend_parse_parameters_none() == FAILURE) {
958-
RETURN_THROWS();
959-
}
951+
ZEND_PARSE_PARAMETERS_NONE();
960952

961953
generator = (zend_generator *) Z_OBJ_P(ZEND_THIS);
962954

@@ -977,9 +969,7 @@ ZEND_METHOD(Generator, next)
977969
{
978970
zend_generator *generator;
979971

980-
if (zend_parse_parameters_none() == FAILURE) {
981-
RETURN_THROWS();
982-
}
972+
ZEND_PARSE_PARAMETERS_NONE();
983973

984974
generator = (zend_generator *) Z_OBJ_P(ZEND_THIS);
985975

@@ -1070,9 +1060,7 @@ ZEND_METHOD(Generator, getReturn)
10701060
{
10711061
zend_generator *generator;
10721062

1073-
if (zend_parse_parameters_none() == FAILURE) {
1074-
RETURN_THROWS();
1075-
}
1063+
ZEND_PARSE_PARAMETERS_NONE();
10761064

10771065
generator = (zend_generator *) Z_OBJ_P(ZEND_THIS);
10781066

ext/json/json.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,7 @@ static PHP_FUNCTION(json_decode)
339339
Returns the error code of the last json_encode() or json_decode() call. */
340340
static PHP_FUNCTION(json_last_error)
341341
{
342-
if (zend_parse_parameters_none() == FAILURE) {
343-
RETURN_THROWS();
344-
}
342+
ZEND_PARSE_PARAMETERS_NONE();
345343

346344
RETURN_LONG(JSON_G(error_code));
347345
}
@@ -351,9 +349,7 @@ static PHP_FUNCTION(json_last_error)
351349
Returns the error string of the last json_encode() or json_decode() call. */
352350
static PHP_FUNCTION(json_last_error_msg)
353351
{
354-
if (zend_parse_parameters_none() == FAILURE) {
355-
RETURN_THROWS();
356-
}
352+
ZEND_PARSE_PARAMETERS_NONE();
357353

358354
RETURN_STRING(php_json_get_error_msg(JSON_G(error_code)));
359355
}

ext/libxml/libxml.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -979,9 +979,7 @@ static PHP_FUNCTION(libxml_get_last_error)
979979
{
980980
xmlErrorPtr error;
981981

982-
if (zend_parse_parameters_none() == FAILURE) {
983-
RETURN_THROWS();
984-
}
982+
ZEND_PARSE_PARAMETERS_NONE();
985983

986984
error = xmlGetLastError();
987985

@@ -1014,9 +1012,7 @@ static PHP_FUNCTION(libxml_get_errors)
10141012

10151013
xmlErrorPtr error;
10161014

1017-
if (zend_parse_parameters_none() == FAILURE) {
1018-
RETURN_THROWS();
1019-
}
1015+
ZEND_PARSE_PARAMETERS_NONE();
10201016

10211017
if (LIBXML(error_list)) {
10221018

@@ -1055,9 +1051,7 @@ static PHP_FUNCTION(libxml_get_errors)
10551051
Clear last error from libxml */
10561052
static PHP_FUNCTION(libxml_clear_errors)
10571053
{
1058-
if (zend_parse_parameters_none() == FAILURE) {
1059-
RETURN_THROWS();
1060-
}
1054+
ZEND_PARSE_PARAMETERS_NONE();
10611055

10621056
xmlResetLastError();
10631057
if (LIBXML(error_list)) {

ext/pdo/pdo.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ PHP_FUNCTION(pdo_drivers)
8585
{
8686
pdo_driver_t *pdriver;
8787

88-
if (zend_parse_parameters_none() == FAILURE) {
89-
RETURN_THROWS();
90-
}
88+
ZEND_PARSE_PARAMETERS_NONE();
9189

9290
array_init(return_value);
9391

0 commit comments

Comments
 (0)