diff options
Diffstat (limited to 'Zend/zend_compile.c')
-rw-r--r-- | Zend/zend_compile.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 1c7f5f1073..953bf6dfd5 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1161,12 +1161,8 @@ static zend_string *add_type_string(zend_string *type, zend_string *new_type) { return zend_string_copy(new_type); } - // TODO: Switch to smart_str? - result = zend_string_alloc(ZSTR_LEN(type) + ZSTR_LEN(new_type) + 1, 0); - memcpy(ZSTR_VAL(result), ZSTR_VAL(type), ZSTR_LEN(type)); - ZSTR_VAL(result)[ZSTR_LEN(type)] = '|'; - memcpy(ZSTR_VAL(result) + ZSTR_LEN(type) + 1, ZSTR_VAL(new_type), ZSTR_LEN(new_type)); - ZSTR_VAL(result)[ZSTR_LEN(type) + ZSTR_LEN(new_type) + 1] = '\0'; + result = zend_string_concat3( + ZSTR_VAL(type), ZSTR_LEN(type), "|", 1, ZSTR_VAL(new_type), ZSTR_LEN(new_type)); zend_string_release(type); return result; } @@ -1243,10 +1239,7 @@ zend_string *zend_type_to_string_resolved(zend_type type, zend_class_entry *scop if (type_mask & MAY_BE_NULL) { zend_bool is_union = !str || memchr(ZSTR_VAL(str), '|', ZSTR_LEN(str)) != NULL; if (!is_union) { - zend_string *nullable_str = zend_string_alloc(ZSTR_LEN(str) + 1, 0); - ZSTR_VAL(nullable_str)[0] = '?'; - memcpy(ZSTR_VAL(nullable_str) + 1, ZSTR_VAL(str), ZSTR_LEN(str)); - ZSTR_VAL(nullable_str)[ZSTR_LEN(nullable_str)] = '\0'; + zend_string *nullable_str = zend_string_concat2("?", 1, ZSTR_VAL(str), ZSTR_LEN(str)); zend_string_release(str); return nullable_str; } |