Skip to content

ext/date: various optimizations of _php_gettimeofday #18560

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jorgsowa
Copy link
Contributor

Pre-allocated size of array for _php_gettimeofday and improved typing.

@jorgsowa jorgsowa requested review from bukka and derickr as code owners May 14, 2025 20:49
@jorgsowa jorgsowa changed the title ext/date: various optimizations ext/date: various optimizations of _php_gettimeofday May 14, 2025
Copy link
Member

@devnexen devnexen left a comment

Choose a reason for hiding this comment

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

changes themselves are correct, optimisation"s" is only about the output though.

$get_as_float = false;

// Calling gettimeofday() with all possible arguments
var_dump( gettimeofday($get_as_float) );
Copy link
Member

Choose a reason for hiding this comment

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

Please don't change test cases at the same time as actual code changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't change the test case. It's only removal of unnecessary variables and comments. There is no functional change.

@@ -66,7 +66,7 @@ static void _php_gettimeofday(INTERNAL_FUNCTION_PARAMETERS, int mode)

offset = timelib_get_time_zone_info(tp.tv_sec, get_timezone_info());

array_init(return_value);
array_init_size(return_value, 4);
Copy link
Member

Choose a reason for hiding this comment

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

Does this really improve things a lot?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's the same change as in recent PR #18382

Not much, but still something.

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