Open xee5ch opened 6 years ago
Hey @xee5ch thanks for the issue!
Is it not more performant for large objects to just iterate over unsorted properties
Great question! I don't know the answer to that. We have a benchmark suite already set up so you could have a go at running the benchmarks, modifying the code and rerunning the benchmarks. I'd be interested to see what happens! And we'd welcome a PR to make things faster!
Ok let me review the documentation about running the benchmark suite. I was talking with that friend when stepping through the functions called via chai and I presume it does not make a large difference for small objects, but large object comparison could be slow if you sort the keys of both objects.
I will work on a test case, then post back with samples, the benchmark difference, and of course the code change required.
Today, when reserving the
objectEqual
function in this library while evaluatingdeep.equal
call stacks in a chai test harness, I observed that when comparingobjectEqual()
from thedefault
branch inextensiveDeepEqualByType)
it sorts the keys.https://github.com/chaijs/deep-eql/blob/04d6da6518f8ddc288638ca42503752028810120/index.js#L418
https://github.com/chaijs/deep-eql/blob/04d6da6518f8ddc288638ca42503752028810120/index.js#L419
Is it not more performant for large objects to just iterate over unsorted properties with something like
hasOwnProperty
on therightHandProperty
properties? If so, I can make a PR.