Open
Description
I was doing some profiling the other day and was mildly surprised to find that a lot of the time spent in Svelte — possibly even most? — was in safe_not_equal
. It occurs to me that we might see some performance gains by changing the implementations thusly:
+function is_mutable(type) {
+ return type === 'object' || type === 'function';
+}
+
export function safe_not_equal(a, b) {
- return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
+ return a !== b || a && is_mutable(typeof a);
}
export function not_equal(a, b) {
- return a != a ? b == b : a !== b;
+ return a !== b;
}
The downside is that setting x
to NaN
would trigger an update if x
was already NaN
. But I'm pretty sure that's a small enough edge case that we needn't worry about it