-
Notifications
You must be signed in to change notification settings - Fork 7.9k
uri: Remove php_uri_parse()
and php_uri_free()
#19624
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2640,14 +2640,19 @@ static char *php_openssl_get_url_name(const char *resourcename, | |
return NULL; | ||
} | ||
|
||
uri_internal_t *internal_uri = php_uri_parse(uri_parser, resourcename, resourcenamelen, true); | ||
if (internal_uri == NULL) { | ||
void *parsed = uri_parser->parse_uri(resourcename, resourcenamelen, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We discussed these design details a while ago here: #18672 (comment) Back then, you suggested a simple API for internal usage (that's why In the last sentence of my response (#18672 (comment)), I mentioned the reason why I think these API functions are important: they can hide the implementation details. E.g. if we remove the PHPAPI functions then we won't be able to change the signature (e.g. add new parameters) without causing a serious BC break for any caller of the API. What made you change your mind in this question? What kind of future changes do you have in mind? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note how my last reply said "I'll look into this more at a later time" and this is what happened here. I still believe that simplifying the handler itself would be the right decision. When I worked my way through the code, I realized that the
I'm hoping to overall reduce the amount of stuff passed by pointer, since this adds quite a bit of overhead and makes the code harder to reason about. Specifically However I see that this PR by itself might not be particularly convincing. I can offer to prepare a little larger PR for you to see the "full picture" that I can then split into its individual parts, how does that sound? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yeah, when rereading it, I was sure that the time had come now ^^
Thanks for the efforts!
Yes, that sounds much better! I'm happy about performance/code quality improvements as long as the code continues to offer its users some kind of protection against future BC breaks. Basically, that's my main - and probably only - cornerstone :) |
||
/* base_url */ NULL, /* errors */ NULL, /* silent */ true); | ||
if (parsed == NULL) { | ||
return NULL; | ||
} | ||
uri_internal_t internal_uri = { | ||
.parser = uri_parser, | ||
.uri = parsed, | ||
}; | ||
|
||
char * url_name = NULL; | ||
zval host_zv; | ||
zend_result result = php_uri_get_host(internal_uri, URI_COMPONENT_READ_RAW, &host_zv); | ||
zend_result result = php_uri_get_host(&internal_uri, URI_COMPONENT_READ_RAW, &host_zv); | ||
if (result == SUCCESS && Z_TYPE(host_zv) == IS_STRING) { | ||
const char * host = Z_STRVAL(host_zv); | ||
size_t len = Z_STRLEN(host_zv); | ||
|
@@ -2662,7 +2667,7 @@ static char *php_openssl_get_url_name(const char *resourcename, | |
} | ||
} | ||
|
||
php_uri_free(internal_uri); | ||
uri_parser->free_uri(parsed); | ||
zval_ptr_dtor(&host_zv); | ||
|
||
return url_name; | ||
|