Skip to content

Update: prevent superfluous set updates#18

Merged
oliverfoster merged 2 commits intomasterfrom
issue/17
Jul 10, 2025
Merged

Update: prevent superfluous set updates#18
oliverfoster merged 2 commits intomasterfrom
issue/17

Conversation

@danielghost
Copy link
Copy Markdown
Contributor

Fixes #17.

Update

  • Prevent superfluous set updates by removing duplicates from the queue and intersection lookups.

*/
update() {
const updateSubsets = !this._queuedChanges?.length
const queuedChanges = [...new Set(this._queuedChanges)];
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it better to check if the queue already contains the model before adding, rather than removing duplicates later?

Copy link
Copy Markdown
Member

@oliverfoster oliverfoster Jul 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@oliverfoster oliverfoster merged commit 21b3b0d into master Jul 10, 2025
1 check passed
@github-project-automation github-project-automation bot moved this from Needs Reviewing to Recently Released in adapt_framework: The TODO Board Jul 10, 2025
@oliverfoster oliverfoster deleted the issue/17 branch July 10, 2025 11:51
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 1.2.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove duplicated sets in _queuedChanges

2 participants