-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Introduce ASIntegerMap, improve our changeset handling #trivial #405
Conversation
4eb98a3
to
2183b38
Compare
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.
Awesome changes! Would be great to have unit test(s) for +[ASIntegerMap mapForUpdateWithOldCount:deleted:inserted]
though.
Source/Details/ASIntegerMap.h
Outdated
@interface ASIntegerMap : NSObject <NSCopying> | ||
|
||
/** | ||
* Creates an map based on the specified update to an array. |
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.
Nit: "a map"
Rename to ASIntegerMap License header
2183b38
to
1f994f2
Compare
Good calls @nguyenhuy and thanks for reviewing it. Addressed, will merge after CI. |
Super glad that you put up tests 🎆 Merge away! |
Generated by 🚫 Danger |
…ureGroup#405) * Introduce ASIntegerMap, improve our changeset handling Rename to ASIntegerMap License header * Add unit tests for ASIntegerMap * Address nit
This is a larger, more risky follow-up to #404 .
This introduces ASIntegerMap, which is a pretty wrapper around unordered_map. It also has some handy logic for generating mappings across updates, and there are singletons for identity and null mappings.
This simplifies and unifies our tracking of index changes at the section and item levels, and improves performance by storing these mappings in an immutable store rather than recomputing them for each query.
For most updates, most of the mappings will be the shared identity mapping, and it'll be easy to tell.
Note: I know a lot of code was added to _ASHierarchyChangeSet, but it's also become much more powerful. You can now get O(1) bi-directional index path and section index mappings with very little pre-computation cost.
Note: I haven't tested this against Pinterest yet, only against the sample project in #397 (it works there) and I've done some manual tests.