mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Use STR_COPY() instead of STR_DUP() where possible
This commit is contained in:
parent
a25a1ba0ef
commit
042c937f69
5 changed files with 7 additions and 6 deletions
|
@ -1083,7 +1083,7 @@ static int zend_merge_property(zval *value TSRMLS_DC, int num_args, va_list args
|
|||
zend_object_handlers *obj_ht = va_arg(args, zend_object_handlers *);
|
||||
zval member;
|
||||
|
||||
ZVAL_STR(&member, STR_DUP(hash_key->key, 0));
|
||||
ZVAL_STR(&member, STR_COPY(hash_key->key));
|
||||
obj_ht->write_property(obj, &member, value, 0 TSRMLS_CC);
|
||||
zval_ptr_dtor(&member);
|
||||
}
|
||||
|
|
|
@ -2021,7 +2021,7 @@ void zend_do_begin_method_call(znode *left_bracket TSRMLS_DC) /* {{{ */
|
|||
if (Z_TYPE(name) != IS_STRING) {
|
||||
zend_error_noreturn(E_COMPILE_ERROR, "Method name must be a string");
|
||||
}
|
||||
Z_STR(name) = STR_DUP(Z_STR(name), 0);
|
||||
Z_STR(name) = STR_COPY(Z_STR(name));
|
||||
FREE_POLYMORPHIC_CACHE_SLOT(last_op->op2.constant);
|
||||
last_op->op2.constant =
|
||||
zend_add_func_name_literal(CG(active_op_array), &name TSRMLS_CC);
|
||||
|
@ -7233,7 +7233,7 @@ void zend_do_use_non_class(znode *ns_name, znode *new_name, int is_global, int i
|
|||
}
|
||||
|
||||
if (case_sensitive) {
|
||||
lookup_name = STR_DUP(Z_STR_P(name), 0);
|
||||
lookup_name = STR_COPY(Z_STR_P(name));
|
||||
} else {
|
||||
lookup_name = STR_ALLOC(Z_STRLEN_P(name), 0);
|
||||
zend_str_tolower_copy(lookup_name->val, Z_STRVAL_P(name), Z_STRLEN_P(name));
|
||||
|
|
|
@ -49,7 +49,8 @@ static void copy_zend_constant(zval *zv)
|
|||
|
||||
Z_PTR_P(zv) = malloc(sizeof(zend_constant)/*, c->flags & CONST_PERSISTENT*/);
|
||||
memcpy(Z_PTR_P(zv), c, sizeof(zend_constant));
|
||||
c->name = STR_DUP(c->name, c->flags & CONST_PERSISTENT);
|
||||
//??? c->name = STR_DUP(c->name, c->flags & CONST_PERSISTENT);
|
||||
c->name = STR_COPY(c->name);
|
||||
//??? if (!(c->flags & CONST_PERSISTENT)) {
|
||||
zval_copy_ctor(&c->value);
|
||||
//??? }
|
||||
|
|
|
@ -1414,7 +1414,7 @@ ZEND_API int zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str
|
|||
p = ht->arData + idx;
|
||||
if (p->key) {
|
||||
if (duplicate) {
|
||||
*str_index = STR_DUP(p->key, 0);
|
||||
*str_index = STR_COPY(p->key);
|
||||
} else {
|
||||
*str_index = p->key;
|
||||
}
|
||||
|
|
|
@ -276,7 +276,7 @@ static zend_function *_copy_function(zend_function *fptr TSRMLS_DC) /* {{{ */
|
|||
zend_function *copy_fptr;
|
||||
copy_fptr = emalloc(sizeof(zend_function));
|
||||
memcpy(copy_fptr, fptr, sizeof(zend_function));
|
||||
copy_fptr->internal_function.function_name = STR_DUP(fptr->internal_function.function_name, 0);
|
||||
copy_fptr->internal_function.function_name = STR_COPY(fptr->internal_function.function_name);
|
||||
return copy_fptr;
|
||||
} else {
|
||||
/* no copy needed */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue