Skip to content

Avoid allocation in zend_enum_get_case_cstr()#18239

Merged
ndossche merged 1 commit intophp:masterfrom
ndossche:zend-enum-cstr-no-alloc
Apr 4, 2025
Merged

Avoid allocation in zend_enum_get_case_cstr()#18239
ndossche merged 1 commit intophp:masterfrom
ndossche:zend-enum-cstr-no-alloc

Conversation

@ndossche
Copy link
Member

@ndossche ndossche commented Apr 3, 2025

Future uses of this internal API are planned, and we can easily avoid an allocation by factoring out the common code.

Future uses of this internal API are planned, and we can easily avoid an
allocation by factoring out the common code.
@ndossche ndossche marked this pull request as ready for review April 3, 2025 19:02
@ndossche ndossche requested a review from iluuu1994 April 3, 2025 19:02
Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

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

MSTM.

Follow-up, maybe there should be a new ZEND_API that takes a C string with its length to prevent the strlen() computation for literal strings?

Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@ndossche
Copy link
Member Author

ndossche commented Apr 4, 2025

Follow-up, maybe there should be a new ZEND_API that takes a C string with its length to prevent the strlen() computation for literal strings?

Sure. Will do that for my other work that prompted this PR (soon).

@ndossche ndossche merged commit d80682e into php:master Apr 4, 2025
9 checks passed
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