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

Introduce ASIntegerMap, improve our changeset handling #trivial #405

Merged
merged 3 commits into from
Jul 5, 2017

Conversation

Adlai-Holler
Copy link
Member

@Adlai-Holler Adlai-Holler commented Jul 1, 2017

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.

@Adlai-Holler Adlai-Holler changed the title Introduce ASIntegerTable, improve our changeset handling #trivial Introduce ASIntegerMap, improve our changeset handling #trivial Jul 1, 2017
Copy link
Member

@nguyenhuy nguyenhuy left a 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.

@interface ASIntegerMap : NSObject <NSCopying>

/**
* Creates an map based on the specified update to an array.
Copy link
Member

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
@Adlai-Holler
Copy link
Member Author

Good calls @nguyenhuy and thanks for reviewing it. Addressed, will merge after CI.

@nguyenhuy
Copy link
Member

Super glad that you put up tests 🎆 Merge away!

@ghost
Copy link

ghost commented Jul 5, 2017

1 Warning
⚠️ This is a big PR, please consider splitting it up to ease code review.

Generated by 🚫 Danger

@Adlai-Holler Adlai-Holler merged commit d00ed24 into master Jul 5, 2017
@Adlai-Holler Adlai-Holler deleted the ASImprovedChangeset branch July 5, 2017 20:29
bernieperez pushed a commit to AtomTickets/Texture that referenced this pull request Apr 25, 2018
…ureGroup#405)

* Introduce ASIntegerMap, improve our changeset handling

Rename to ASIntegerMap

License header

* Add unit tests for ASIntegerMap

* Address nit
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.

None yet

2 participants