Skip to content

Commit dcac024

Browse files
authored
spl: Avoid pointless copies for internal construction calls (php#20610)
1 parent 56795d2 commit dcac024

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

ext/spl/spl_directory.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -480,9 +480,8 @@ static spl_filesystem_object *spl_filesystem_object_create_info(zend_string *fil
480480
RETVAL_OBJ(&intern->std);
481481

482482
if (ce->constructor->common.scope != spl_ce_SplFileInfo) {
483-
ZVAL_STR_COPY(&arg1, file_path);
483+
ZVAL_STR(&arg1, file_path);
484484
zend_call_method_with_1_params(Z_OBJ_P(return_value), ce, &ce->constructor, "__construct", NULL, &arg1);
485-
zval_ptr_dtor(&arg1);
486485
} else {
487486
spl_filesystem_info_set_filename(intern, file_path);
488487
}
@@ -520,9 +519,8 @@ static spl_filesystem_object *spl_filesystem_object_create_type(int num_args, sp
520519
}
521520

522521
if (ce->constructor->common.scope != spl_ce_SplFileInfo) {
523-
ZVAL_STR_COPY(&arg1, source->file_name);
522+
ZVAL_STR(&arg1, source->file_name);
524523
zend_call_method_with_1_params(Z_OBJ_P(return_value), ce, &ce->constructor, "__construct", NULL, &arg1);
525-
zval_ptr_dtor(&arg1);
526524
} else {
527525
intern->file_name = zend_string_copy(source->file_name);
528526
intern->path = spl_filesystem_object_get_path(source);
@@ -549,11 +547,9 @@ static spl_filesystem_object *spl_filesystem_object_create_type(int num_args, sp
549547
}
550548

551549
if (ce->constructor->common.scope != spl_ce_SplFileObject) {
552-
ZVAL_STR_COPY(&arg1, source->file_name);
553-
ZVAL_STR_COPY(&arg2, open_mode);
550+
ZVAL_STR(&arg1, source->file_name);
551+
ZVAL_STR(&arg2, open_mode);
554552
zend_call_method_with_2_params(Z_OBJ_P(return_value), ce, &ce->constructor, "__construct", NULL, &arg1, &arg2);
555-
zval_ptr_dtor(&arg1);
556-
zval_ptr_dtor(&arg2);
557553
} else {
558554
intern->file_name = source->file_name;
559555
intern->path = spl_filesystem_object_get_path(source);

0 commit comments

Comments
 (0)