Commit f0fa9c748a7 for php.net
commit f0fa9c748a774ba9c8359fa9d97fde1f63976800
Author: DanielEScherzer <daniel.e.scherzer@gmail.com>
Date: Thu May 29 11:11:00 2025 -0700
zend_ast.c: use `smart_str_appendc` for appending single characters (#18703)
Slightly more performant
diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c
index 5104aad3510..26a0cbd16ca 100644
--- a/Zend/zend_ast.c
+++ b/Zend/zend_ast.c
@@ -1871,7 +1871,7 @@ static ZEND_COLD void zend_ast_export_class_no_header(smart_str *str, zend_ast_d
smart_str_appends(str, " {\n");
zend_ast_export_stmt(str, decl->child[2], indent + 1);
zend_ast_export_indent(str, indent);
- smart_str_appends(str, "}");
+ smart_str_appendc(str, '}');
}
static ZEND_COLD void zend_ast_export_attribute_group(smart_str *str, zend_ast *ast, int indent) {
@@ -1899,7 +1899,7 @@ static ZEND_COLD void zend_ast_export_attributes(smart_str *str, zend_ast *ast,
for (i = 0; i < list->children; i++) {
smart_str_appends(str, "#[");
zend_ast_export_attribute_group(str, list->child[i], indent);
- smart_str_appends(str, "]");
+ smart_str_appendc(str, ']');
if (newlines) {
smart_str_appendc(str, '\n');
@@ -2060,7 +2060,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
case ZEND_AST_OP_ARRAY:
smart_str_appends(str, "Closure(");
smart_str_append(str, zend_ast_get_op_array(ast)->op_array->function_name);
- smart_str_appends(str, ")");
+ smart_str_appendc(str, ')');
break;
case ZEND_AST_CONSTANT_CLASS:
smart_str_appendl(str, "__CLASS__", sizeof("__CLASS__")-1);
@@ -2427,9 +2427,9 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
case ZEND_AST_CALL: {
zend_ast *left = ast->child[0];
if (left->kind == ZEND_AST_ARROW_FUNC || left->kind == ZEND_AST_CLOSURE) {
- smart_str_appends(str, "(");
+ smart_str_appendc(str, '(');
zend_ast_export_ns_name(str, left, 0, indent);
- smart_str_appends(str, ")");
+ smart_str_appendc(str, ')');
} else {
zend_ast_export_ns_name(str, left, 0, indent);
}
@@ -2679,9 +2679,9 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
smart_str_appends(str, " {\n");
zend_ast_export_ex(str, ast->child[1], 0, indent + 1);
zend_ast_export_indent(str, indent);
- smart_str_appends(str, "}");
+ smart_str_appendc(str, '}');
} else {
- smart_str_appends(str, ";");
+ smart_str_appendc(str, ';');
}
break;
case ZEND_AST_TRAIT_PRECEDENCE: