Skip to content

Conversation

@twose
Copy link
Member

@twose twose commented Sep 27, 2023

before

image

after

image

@twose twose requested a review from devnexen September 27, 2023 18:27
* anything apart from the protocol */
if (protocol != NULL) {
stream = php_stream_xport_create(protocol, protocollen, 0, 0, NULL, NULL, NULL, NULL, NULL);
stream = php_stream_xport_create(protocol, strlen(protocol), 0, 0, NULL, NULL, NULL, NULL, NULL);
Copy link
Member

Choose a reason for hiding this comment

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

IMHO keeping the variable makes sense, as the compiler can elide the call to strlen() when the value is constant.

Copy link
Member Author

@twose twose Sep 28, 2023

Choose a reason for hiding this comment

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

This function is inherently "heavy", and it's not a high-frequency operation, the calculation of the text length of the protocol isn't a key factor affecting performance. Therefore, I have no preference for the way of calculation. In the new commit, I've added a const modifier to the protocol to avoid generating compile warnings and used sizeof(protocol - 1) to enhance readability and 100% ensure that it would be comfortable in terms of performance.

@twose twose force-pushed the fix_export_proto_8_1 branch from a32368e to 08ee346 Compare September 28, 2023 10:00
@ndossche ndossche assigned ndossche and unassigned ndossche Sep 28, 2023
@twose twose closed this in b5da98b Sep 29, 2023
@twose twose deleted the fix_export_proto_8_1 branch September 29, 2023 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants