Skip to content

Conversation

TimWolla
Copy link
Member

See individual commits.

…rnal_uri()`

It's impossible for this function to return `NULL`, since it will always return
a positive offset into a struct.
Currently the `php_uri_get_*()` functions call into `php_uri_get_property()`
with a constant `php_uri_property_name`. This name will then be used to look up
the correct property handler by a function in a different compilation unit.

Improve this by making `uri_property_handler_from_internal_uri` take a
`php_uri_parser` rather than a `uri_internal_t`, defining it in a header as
inlinable (and renaming it to better match its updated purpose).

This allows the compiler to fully inline `php_uri_get_property()`, such that no
dynamic lookups will need to happen.
Spelling out the effective implementation explicitly is not much longer than
going through `php_uri_get_property()`, but much more explicit in what is
happening.
@TimWolla
Copy link
Member Author

Before - After:

image

Copy link
Member

@nielsdos nielsdos left a comment

Choose a reason for hiding this comment

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

Makes a lot of sense, also good for the branch predictor

@TimWolla TimWolla merged commit 3e9caf5 into php:master Sep 11, 2025
9 checks passed
@TimWolla TimWolla deleted the uri-getters-inline branch September 11, 2025 21:05
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.

3 participants