Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collection performance improvements #488

Merged

Conversation

Daniel-Svensson
Copy link
Member

@Daniel-Svensson Daniel-Svensson commented Feb 7, 2024

Remove unnecessary calls to *.Contains()

  • Combine .!Contains with .Add into a single Add operation
  • Replace IndexOf with Contains (faster remove from EntityCollection)

Go though usages of ContainsKey

  • Use TryAdd instead if followed by Add
  • Use TryGet if followed by fetching value
  • Switch to HashSet if value is not used

Replace unneccesary IndexOf calls

  • When access EntitySet of EntityCollection using CollectioViewSource add and Contains checks are much faster O(1) instead of O(n)

This translates to roughly ~9% perf improvement for adding 50 000 entities to an EntityCollection.

* Combine .!Contains with .Add into a single Add operation
* Replace IndexOf with Contains (faster remove from EntityCollection)
* Use TryAdd instead if followed by Add
* Use TryGet if followed by fetching value
* Switch to HashSet if value is not used
@Daniel-Svensson Daniel-Svensson enabled auto-merge (squash) February 8, 2024 10:22
@Daniel-Svensson Daniel-Svensson changed the title Various performance improvements Various collection performance improvements Feb 8, 2024
@Daniel-Svensson Daniel-Svensson changed the title Various collection performance improvements Collection performance improvements Feb 8, 2024
Copy link

sonarcloud bot commented Feb 8, 2024

@Daniel-Svensson Daniel-Svensson merged commit 46b789d into OpenRIAServices:main Feb 8, 2024
5 checks passed
@Daniel-Svensson Daniel-Svensson deleted the containss_perf branch February 8, 2024 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant