-
Notifications
You must be signed in to change notification settings - Fork 12
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
Avoid set several times HACachedStates #56
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #56 +/- ##
=======================================
Coverage 99.87% 99.87%
=======================================
Files 50 50
Lines 1593 1595 +2
=======================================
+ Hits 1591 1593 +2
Misses 2 2 ☔ View full report in Codecov by Sentry. |
Source/Caches/HACacheKeyStates.swift
Outdated
if let additions = info.incoming.add { | ||
for (entityId, updates) in additions { | ||
if var currentState = states[entityId] { | ||
if var currentState = updatedEntities.first(where: { $0.entityId == entityId }), | ||
let index = updatedEntities.firstIndex(of: currentState) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now pretty bad at performance - at least two O(N) added on top of another O(N) enumeration. It's also going to require another step to segment by dictionary again at the end, which is a lot of overhead for all of these changes.
I think it may be better to make the 'all' access lazy, or give HACachedStates an initializer that takes a dictionary, or something along those lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shame on me, I made it worse than before :P
I just updated it, I went for dealing with a dictionary for the whole process to avoid wasting by look inside an array and endup creating the cache in the end with an initializer that receives a dictionary as you said
931f518
to
91a2fcc
Compare
91a2fcc
to
57d4c61
Compare
c4f6d6f
to
950b1e9
Compare
No description provided.