Skip to content

runtime: avoid an allocation in (*time.Timer).Reset #4890

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
May 16, 2025

Conversation

eliasnaur
Copy link
Contributor

No description provided.

Copy link
Member

@dgryski dgryski left a comment

Choose a reason for hiding this comment

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

LGTM. My only question is if we can just reuse the timer struct as-is and we don't need to reset or update any other fields.

@eliasnaur eliasnaur force-pushed the push-oskwypvzoquy branch from 834ec50 to df1f8b7 Compare May 10, 2025 08:02
@eliasnaur
Copy link
Contributor Author

Good point. PTAL.

@deadprogram
Copy link
Member

Looks good now, thanks for the improvement @eliasnaur and to @dgryski for review/feedback.

Now merging.

@deadprogram deadprogram merged commit 180662f into tinygo-org:dev May 16, 2025
19 checks passed
@eliasnaur eliasnaur deleted the push-oskwypvzoquy branch May 20, 2025 10:29
Copy link
Member

@aykevl aykevl left a comment

Choose a reason for hiding this comment

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

A bit late, LGTM but there's a small nit in that the documentation now doesn't match the function. Might be a good idea to fix in a separate PR if you want.

@@ -117,11 +117,11 @@ func addTimer(tim *timerNode) {

// removeTimer is the implementation of time.stopTimer. It removes a timer from
// the timer queue, returning true if the timer is present in the timer queue.
Copy link
Member

Choose a reason for hiding this comment

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

This comment is now incorrect: it doesn't return a bool anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

eliasnaur added a commit to eliasnaur/tinygo that referenced this pull request May 21, 2025
I forgot to change the comment in PR tinygo-org#4890.
deadprogram pushed a commit that referenced this pull request May 22, 2025
I forgot to change the comment in PR #4890.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants