File tree Expand file tree Collapse file tree 1 file changed +2
-4
lines changed Expand file tree Collapse file tree 1 file changed +2
-4
lines changed Original file line number Diff line number Diff line change @@ -226,13 +226,11 @@ runtimeFunctions.retire = `const retire = () => {
226226/**
227227 * Converts NaN to zero. Used to match Scratch's string-to-number.
228228 * Unlike (x || 0), -0 stays as -0 and is not converted to 0.
229- * This function is written in this specific way to make it easy for browsers to inline.
230- * We've found that calling isNaN() causes slowdowns in Firefox, so instead we utilize the
231- * fact that NaN is the only JavaScript value that does not equal itself.
229+ * This function needs to be written such that it's very easy for browsers to inline it.
232230 * @param {number } value A number. Might be NaN.
233231 * @returns {number } A number. Never NaN.
234232 */
235- runtimeFunctions . toNotNaN = `const toNotNaN = value => value === value ? value : 0 ` ;
233+ runtimeFunctions . toNotNaN = `const toNotNaN = value => Number.isNaN( value) ? 0 : value ` ;
236234
237235/**
238236 * Scratch cast to boolean.
You can’t perform that action at this time.
0 commit comments