Skip to content
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

⚡️ Performance: audit creating new objects in game logic #304

Open
3 tasks done
JoshuaKGoldberg opened this issue Aug 19, 2022 · 0 comments
Open
3 tasks done
Labels
area: performance Improving the speed of games. package: timehandlr status: accepting prs Go ahead and send a pull request to resolve this issue!

Comments

@JoshuaKGoldberg
Copy link
Member

Feature Request Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have pulled the latest main branch of the repository.
  • I have searched for related issues and found none that matched my issue.

Overview

Browser GC (garbage collection) happens sporadically throughout a webpage's runtime and can cause little blips of bad performance. It's best to avoid creating new objects that will cause GC to have to run.

One common culprit is inline literals such as [] and {}. I know I've seen them at least in the timehandlr codebase. I should do an audit of where those are created and try to avoid them.

Additional Info

One common strategy is to use shared empty objects -- as long as nothing modifies them.

export const emptyArray = [] as const;
export const emptyObject = [] as const;
@JoshuaKGoldberg JoshuaKGoldberg added status: accepting prs Go ahead and send a pull request to resolve this issue! package: timehandlr area: performance Improving the speed of games. labels Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: performance Improving the speed of games. package: timehandlr status: accepting prs Go ahead and send a pull request to resolve this issue!
Projects
None yet
Development

No branches or pull requests

1 participant