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
Refactor mb_substitute_character() to use string|int fast ZPP check #5359
Conversation
43d0336
to
39e7db6
Compare
If I'm not mistaken, the sole parameter of |
It's better described as I just thought of a trick to reduce it from 4 to 3 ZPP checks, but I think the way to solve this ludicrous over engineering is to have a Fast ZPP macro which can check if an argument is integer or string, in the same way as we have one for |
39e7db6
to
b35b2b7
Compare
Well I decided to use a big switch instead and implement strict_types handling manually, still can't use actual type hints otherwise a ZPP mismatch is emitted. |
436d0f2
to
45859e5
Compare
45859e5
to
7e62f69
Compare
This is now based on #5449 |
0daff00
to
514095b
Compare
a4c9a2f
to
94b1d8e
Compare
@nikic can you review this? |
ext/mbstring/mbstring.c
Outdated
} | ||
break; | ||
if (substitute_character != NULL) { | ||
if (zend_string_equals_literal(substitute_character, "none")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These were case-insensitive previously, you can use _ci.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, nice catch!
ext/mbstring/mbstring.c
Outdated
} | ||
/* Invalid string value */ | ||
zend_argument_value_error(1, "must be 'none', 'long' or 'entity'"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zend_argument_value_error(1, "must be 'none', 'long' or 'entity'"); | |
zend_argument_value_error(1, "must be 'none', 'long', 'entity' or a valid codepoint"); |
Maybe? As is, it kinda sounds like you can only pass in those strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, adjusted the message accordingly.
Using the new Fast ZPP API for string|int|null This also fixes Bug #79448 which was too disruptive to fix in PHP 7.x
94b1d8e
to
7dd332f
Compare
Targeting master and rework of #5348
I'm not sure what the best way was to handle int|string with ZPP so I came up with this horror... Any better idea or should I just use a zval and a switch block again?