-
Notifications
You must be signed in to change notification settings - Fork 8k
uri: Inline parser
and uri
into uri_object_t
#19906
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
Conversation
const uri_internal_t *internal_base_url = &base_url_object->internal; | ||
URI_ASSERT_INITIALIZATION(internal_base_url); | ||
ZEND_ASSERT(internal_base_url->parser == uri_parser); | ||
base_url = internal_base_url->uri; | ||
ZEND_ASSERT(base_url_object->uri != NULL); | ||
ZEND_ASSERT(base_url_object->parser == uri_parser); | ||
base_url = base_url_object->uri; |
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.
I think the improvement is particularly visible here, since the assertions are no longer mixed with declarations.
Changes performed with Coccinelle with some minor adjustments in places where it choked due to macros: @@ expression e; @@ - Z_URI_INTERNAL_P(e) + &Z_URI_OBJECT_P(e)->internal @@ expression e; @@ - uri_internal_from_obj(e) + &uri_object_from_obj(e)->internal
While a `NULL` pointer to `zend_object` would result in `->internal` also sitting at `0`, this is not a particularly useful assertion to have. Instead just assert that we have a parsed `->uri` available. Changes made with Coccinelle + some manual adjustments: @@ uri_internal_t *u; expression e; @@ u = &Z_URI_OBJECT_P(e)->internal ... when != u - URI_ASSERT_INITIALIZATION(u); + ZEND_ASSERT(u->uri != NULL); @@ uri_internal_t *u; expression e; @@ u = &uri_object_from_obj(e)->internal ... when != u - URI_ASSERT_INITIALIZATION(u); + ZEND_ASSERT(u->uri != NULL);
After this, `uri_internal_t` will only be used when interacting with the URI parsers without having a full-blown URI object. Changes made with Coccinelle and some manual adjustments: @@ identifier u; expression e; @@ - uri_internal_t *u = &e->internal; + uri_object_t *u = e; @@ uri_object_t *u; identifier t; @@ - u->internal.t + u->t
cc24615
to
1f9d9ec
Compare
Rebased after the merge of #19903. |
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.
RM approval 👍 No technical review performed
This PR includes and depends on #19903 with the first 2 commits. The PRs are independent for better commit history after merging.The purpose of this change is to improve readability of the code by avoiding:
.internal
member that does not provide a value-add when already dealing with URI objects and just adds needless verbosity.