Update: prevent superfluous set updates#18
Conversation
| */ | ||
| update() { | ||
| const updateSubsets = !this._queuedChanges?.length | ||
| const queuedChanges = [...new Set(this._queuedChanges)]; |
There was a problem hiding this comment.
Is it better to check if the queue already contains the model before adding, rather than removing duplicates later?
There was a problem hiding this comment.
It makes no difference with arrays at this size.
It is difficult to quantify which is more performant.
It may be cheaper to remove duplicates as the list grows, as at each addition, there would be fewer duplicate comparisons and the list would remain as short as possible. However, the overhead of performing a duplicate comparison each time may cost more than performing a single duplicate check on a larger set later.
It entirely depends on the quantity of duplicate and non-duplicate items, and the frequency of additions. Then, whether it is more important to add quickly and process slowly or vice-versa, or if RAM usage is important than processing speed. etc
|
🎉 This PR is included in version 1.2.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Fixes #17.
Update