jotaijs / jotai-scope

MIT License
55 stars 4 forks source link

Spread is faster than Array.from #14

Closed AjaxSolutions closed 10 months ago

AjaxSolutions commented 10 months ago

Minor improvement suggestion.

Array.from vs Spread

const isEqualSet = (a: Set<unknown>, b: Set<unknown>) =>
  a === b || (a.size === b.size && Array.from(a).every((v) => b.has(v)));

vs.

const isEqualSet = (a, b) =>
  a === b || (a.size === b.size && [...a].every(v => b.has(v)));
dai-shi commented 10 months ago
image

Array.from seems faster in my case.

AjaxSolutions commented 10 months ago
Screenshot 2023-11-01 at 10 37 14 AM

Hmmm... this must be browser dependent. I'm on an old iMac using the MS Edge browser., and spread is faster in my case.

AjaxSolutions commented 10 months ago

OK, I'll close this issue.