Skip to content

[OPTIMIZATION] Refactor: cleaner and faster time formatter#6049

Merged
Hundrec merged 1 commit into
FunkinCrew:dummy/develop-v0.7.5from
HeroEyad:main
Sep 23, 2025
Merged

[OPTIMIZATION] Refactor: cleaner and faster time formatter#6049
Hundrec merged 1 commit into
FunkinCrew:dummy/develop-v0.7.5from
HeroEyad:main

Conversation

@HeroEyad
Copy link
Copy Markdown
Contributor

Description

What changed?

  • replaced repeated Math.pow(10, decimals) calls with a single precomputed factor.

  • simplified the seconds formatting branch into a concise ternary expression.

i made this for performance-wise because Math.pow is relatively expensive compared to arithmetic. The old code recomputed it for every unit, even though it only matters for seconds. now it's computed once.

small gain but measurable in tight loops or frequent calls.

The ternary (u.name == "second" ? ... : ...) makes it clear that seconds are special-cased without spreading logic across multiple branches.

i've also change variable names (u instead of unit)
precomputed factor makes decimals handling self-contained and predictable.

@github-actions github-actions Bot added status: pending triage Awaiting review. size: medium A medium pull request with 100 or fewer changes. pr: haxe PR modifies game code. and removed size: medium A medium pull request with 100 or fewer changes. labels Sep 18, 2025
@Hundrec
Copy link
Copy Markdown
Member

Hundrec commented Sep 18, 2025

Excellent! How's this @MAJigsaw77?

@Hundrec Hundrec added type: optimization Involves a performance issue or a bug which causes lag. size: medium A medium pull request with 100 or fewer changes. status: reviewing internally Under consideration and testing. status: accepted PR was approved for contribution. If it's not already merged, it may be merged on a private branch. and removed status: pending triage Awaiting review. status: reviewing internally Under consideration and testing. labels Sep 18, 2025
@Hundrec Hundrec added this to the 0.7.6 milestone Sep 23, 2025
@Hundrec Hundrec changed the base branch from develop to dummy/develop-v0.7.5 September 23, 2025 23:45
@Hundrec Hundrec merged commit 5e04ec8 into FunkinCrew:dummy/develop-v0.7.5 Sep 23, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: haxe PR modifies game code. size: medium A medium pull request with 100 or fewer changes. status: accepted PR was approved for contribution. If it's not already merged, it may be merged on a private branch. type: optimization Involves a performance issue or a bug which causes lag.

Development

Successfully merging this pull request may close these issues.

2 participants