derbyjs / racer

Realtime model synchronization engine for Node.js
1.18k stars 117 forks source link

setDiffDeep creates unnecessary ops when updating to the same scalar value #255

Closed zmillman closed 5 years ago

zmillman commented 6 years ago

When calling setDiffDeep, if the before and after values are non-object & non-array, a model._set will always be invoked -- even if the two values are equal.

See: https://github.com/derbyjs/racer/blob/3d9cb6ea6d5a8326e7ad51d7bc34542ec20f0e1d/lib/Model/setDiff.js#L59-L65

This is especially noticeable in model.start which has a default behavior of applying updates to the output path with mode = 'diffDeep' and can cause a VERY large number of updates to be propagated in a complex app even where there was no actual change to the data.