TurboWarp / scratch-vm

Scratch VM with a JIT compiler and more features
https://turbowarp.org/
Mozilla Public License 2.0
75 stars 72 forks source link

Remove Function Calls For NaN-to-Number Comparisons With Greater/Less Than #72

Closed Geotale closed 2 years ago

Geotale commented 2 years ago

For greater/less than operators, normal operators (instead of comparison function calls) can be in these cases:

This can be done because string comparisons with numbers and NaN in these scenarios will always return false (for example, "NaN" < "10000" is false, which is the same as NaN < 10000) If this is not done, then the compareLessThanSlow path is taken for each comparison with these values, assuming they include NaN

Geotale commented 2 years ago

I've now realized that, by using !(val1 >= val2), and similarly with <=, you can completely remove all function calls for number + number or NaN comparisons.

GarboMuffin commented 2 years ago

resolved by #73