Skip to content

smart_str* usage refactoring#21410

Draft
Girgias wants to merge 8 commits intophp:masterfrom
Girgias:smart-str-improvements
Draft

smart_str* usage refactoring#21410
Girgias wants to merge 8 commits intophp:masterfrom
Girgias:smart-str-improvements

Conversation

@Girgias
Copy link
Member

@Girgias Girgias commented Mar 11, 2026

Commits should be reviewed individually.

{
smart_str_append_ex(dest, src, false);
}
#define smart_str_append_literal(dest, src) smart_str_appendl_ex(dest, "" src, sizeof(src)-1, false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it might be best to remove the trailing ;

smart_str_appends(str, "[unknown]"); \
} else { \
smart_str_appends(str, Z_STRVAL_P(tmp)); \
smart_str_append(str, Z_STR_P(tmp)); \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"The devil is in the details". I think this little change causes all sort of problems, i.e. strlen() usage vs ZSTR_LEN()

uint32_t *guard = zend_get_recursion_guard(zobj);
zend_string *class_name = Z_OBJ_HANDLER_P(expr, get_class_name)(zobj);
smart_str_appends(buf, ZSTR_VAL(class_name));
smart_str_append(buf, class_name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably ditto.

smart_str_appends(str, ZSTR_VAL(class_name));
smart_str_appends(str, "), ");
smart_str_append_literal(str, "Object(");
smart_str_append(str, class_name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be looked at too.

@ndossche
Copy link
Member

Just using smart_str_appends should be good enough because the strlen will be computed at compile time for literals

@Girgias
Copy link
Member Author

Girgias commented Mar 11, 2026

Just using smart_str_appends should be good enough because the strlen will be computed at compile time for literals

Yeah I wasn't sure about the literal version, happy to just use smart_str_appends().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants