FormidableLabs / react-fast-compare

fastest deep equal comparison for React
MIT License
1.59k stars 54 forks source link

Improve performance by avoiding extra work #52

Closed sbrichardson closed 4 years ago

sbrichardson commented 4 years ago

This version avoids work in a few ways.

  1. Not declaring extra variables
  2. Using while loops without an extra comparison

There may be an extra gain on line 12, if the data isn't expected to have a lot of null values (not so with graphql queries, since they do), you could potentially do the object checks first, then the truthy a && b check.

sbrichardson commented 4 years ago

Closed since even though improving (~slightly), still seeing 2x performance gains over this lib from using lodash.isEqual. I think the benchmarks on your readme may be out of date, or comparing small objects only.

Will resubmit or comment again after more research.