r/SoftwareEngineering • • Sep 07 '26

Branch‑Avoidant Programming

https://easylang.online/blog/branchless
12 Upvotes

5 comments sorted by

View all comments

Show parent comment

2

u/Relevant_Pause_7593 Sep 08 '26

Wat? Eil5 please.

2

u/fagnerbrack Sep 08 '26

Don't use ifs cause compilers generate more CPU work, replace with boolean conditions that resolve as a formula inside value of the variable in the loop.

Doesn't matter for small data 10k, starts to matter on huge loops where micro optimisations are critical

1

u/keelanstuart Sep 08 '26

For those big datasets, you could also remove your loop conditions and use gotos with exceptions... read/write outside your memory? Exit.