5,332
edits
Line 43: | Line 43: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== | ==Booleans== | ||
Multiplications by booleans can be used instead of switch statements. | Multiplications by booleans can be used instead of switch statements. | ||
Line 60: | Line 60: | ||
x = x + 10 * y - 10 * (1-y) | x = x + 10 * y - 10 * (1-y) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Similarly, instead of doing | |||
<syntaxhighlight> | |||
if age > 10: | |||
x+=1 | |||
</syntaxhighlight> | |||
you can just write <code>x += age>10</code>. | |||
These are micro optimizations but they are sometimes useful for speeding up GPU shaders. | These are micro optimizations but they are sometimes useful for speeding up GPU shaders. |