Skip to content

ext/tidy: minor refactorings #19167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 18, 2025
Merged

ext/tidy: minor refactorings #19167

merged 4 commits into from
Jul 18, 2025

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Jul 18, 2025

No description provided.

} else {
return (void *) ZSTR_EMPTY_ALLOC();
}
if (*type == TidyString) {
Copy link
Member

Choose a reason for hiding this comment

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

what s wrong with switch/case ? for only 3 possibilities (and it is not going to change anytime soon), I m not against just to see if this is just taste or anything.

Copy link
Member Author

Choose a reason for hiding this comment

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

The compiler complains if you don't add a return at the end of the function that is unreachable... so I thought forcing it to be 3 branches would be better. But can change back to a switch statement.

Copy link
Member

Choose a reason for hiding this comment

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

the only thing weird I found with the existing code is the break statement after return but usually for enums comparisons especially when more than 2/3 values I prefer switch/case but if the situation forces if/else instead then I m not stubborn about it.

{
TidyBuffer buf;

if(enc) {
ZEND_ASSERT(!ZEND_SIZE_T_UINT_OVFL(ZSTR_LEN(string)));
Copy link
Member

Choose a reason for hiding this comment

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

do not know if an exception should be thrown instead or this. Early morning review so forgive me if I miss something obvious :)

Copy link
Member Author

Choose a reason for hiding this comment

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

This was always checked before calling this function, just making sure it stays that way :)

@devnexen
Copy link
Member

except comments, changes make sense overall.

@Girgias Girgias marked this pull request as ready for review July 18, 2025 12:21
@Girgias Girgias merged commit 419f675 into php:master Jul 18, 2025
9 checks passed
@Girgias Girgias deleted the tidy-nits branch July 18, 2025 12:21
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.

2 participants