reflection: try to avoid manual string comparison#17726
reflection: try to avoid manual string comparison#17726DanielEScherzer wants to merge 2 commits intophp:masterfrom
Conversation
In `is_closure_invoke()` compare with the well known zend_string `ZEND_STR_MAGIC_INVOKE` rather than the underlying literal value.
TimWolla
left a comment
There was a problem hiding this comment.
There is another one in
php-src/ext/reflection/php_reflection.c
Lines 3247 to 3248 in 459fc9d
Make use of the well known zend_string objects `ZEND_STR_MAGIC_INVOKE` and `ZEND_STR_UNKNOWN_CAPITALIZED`
So I tried to fix the other case you found in reflection, but that one is really complicated, since the source being compared is also a char array, and its not clear how to get a zend_string in the case when the char array was extracted from the broader string of I addressed the builtin functions, but I'll note that using |
I think that one could be: That would at least hide away the length comparison and the memcmp in a function, making it a little less verbose. |
FWIW: Those are not calls. Those are just macros hiding a field access on the struct. |
|
There's another use of ZEND_INVOKE_FUNC_NAME in: Line 513 in 0006522 Overall this PR LGTM though. I suggest to retitle it to something like “Compare strings with ZEND_STR_MAGIC_INVOKE rather than ZEND_INVOKE_FUNC_NAME” (or whatever), since you are not just touching reflection here. Feel free to merge when you're happy without another review pass. |
|
@DanielEScherzer is this PR still relevant now that #21402 has been merged? |
In
is_closure_invoke()compare with the well known zend_stringZEND_STR_MAGIC_INVOKErather than the underlying literal value.