Skip to content

Replace repetitive math operations with functions#913

Closed
Saphereye wants to merge 2 commits intocodedeliveryservice:mainfrom
Saphereye:readable-funcs
Closed

Replace repetitive math operations with functions#913
Saphereye wants to merge 2 commits intocodedeliveryservice:mainfrom
Saphereye:readable-funcs

Conversation

@Saphereye
Copy link
Copy Markdown
Contributor

Added these funcs:

  • scale(value, scale) -> value * scale / 1024
    Many values are scaled using constants tuned with 1024.

  • bonus_if(cond, bonus) -> if cond { bonus } else { 0 }
    I believe this could make the code easier to read. And the assembly is identical to the multiplication variant.

  • penalty_if(cond, penalty) -> if cond { -penalty } else { 0 }
    Opposite of bonus_if

@Saphereye Saphereye closed this Apr 20, 2026
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.

1 participant