Skip to content

Conversation

@ike709
Copy link
Collaborator

@ike709 ike709 commented Sep 8, 2025

Best when combined with #2390 but can be merged independently

Just doing this in Or and And saves 370 BooleanOr opcodes and 352 BooleanAnd opcodes in TG, primarily through funny macros:

if(LAZYACCESS(SSlag_switch.measures, DISABLE_NON_OBSJOBS))
gets compiled to
if((SSlag_switch.measures ? (isnum(5) ? (5 > 0 && 5 <= length(SSlag_switch.measures) ? SSlag_switch.measures[5] : null) : SSlag_switch.measures[5]) : null))
which const folds to
if((SSlag_switch.measures ? (isnum(5) ? (5 <= length(SSlag_switch.measures) ? SSlag_switch.measures[5] : null) : SSlag_switch.measures[5]) : null))
which saves a GreaterThan and BooleanAnd on every LAZYACCESS()

@boring-cyborg boring-cyborg bot added the Compiler Involves the OpenDream compiler label Sep 8, 2025
@github-actions github-actions bot added the size/L label Sep 8, 2025
@ike709
Copy link
Collaborator Author

ike709 commented Sep 8, 2025

TODO: Need to cast Number.Value to int in operators like modulo; we already do this at runtime but TryAsConstant() just operates on the floats.

@ike709 ike709 marked this pull request as draft September 8, 2025 20:17
@ike709
Copy link
Collaborator Author

ike709 commented Sep 8, 2025

TODO: Go through the Builtins.cs expressions too

@ZeWaka
Copy link
Collaborator

ZeWaka commented Sep 10, 2025

#885 my child

@ike709 ike709 marked this pull request as ready for review September 15, 2025 17:33
@ike709 ike709 requested a review from wixoaGit September 15, 2025 17:40
@wixoaGit wixoaGit merged commit 66a478d into OpenDreamProject:master Sep 16, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Compiler Involves the OpenDream compiler size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants