-
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
Reduce usage of autorelease pools #968
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,7 +159,7 @@ - (UICollectionViewLayoutAttributes *)layoutAttributesForElement:(ASCollectionEl | |
} | ||
|
||
// Use a set here because some items may span multiple pages | ||
NSMutableSet<UICollectionViewLayoutAttributes *> *result = [NSMutableSet set]; | ||
auto result = [NSMutableSet<UICollectionViewLayoutAttributes *> set]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
for (id pagePtr in pages) { | ||
ASPageCoordinate page = (ASPageCoordinate)pagePtr; | ||
NSArray<UICollectionViewLayoutAttributes *> *allAttrs = [_pageToLayoutAttributesTable objectForPage:page]; | ||
|
@@ -216,7 +216,7 @@ - (ASPageToLayoutAttributesTable *)getAndRemoveUnmeasuredLayoutAttributesPageTab | |
for (UICollectionViewLayoutAttributes *attrs in attrsInPage) { | ||
if (CGRectIntersectsRect(rect, attrs.frame)) { | ||
if (intersectingAttrsInPage == nil) { | ||
intersectingAttrsInPage = [NSMutableArray array]; | ||
intersectingAttrsInPage = [[NSMutableArray alloc] init]; | ||
} | ||
[intersectingAttrsInPage addObject:attrs]; | ||
} | ||
|
@@ -245,7 +245,7 @@ + (ASPageToLayoutAttributesTable *)_unmeasuredLayoutAttributesTableFromTable:(NS | |
contentSize:(CGSize)contentSize | ||
pageSize:(CGSize)pageSize | ||
{ | ||
NSMutableArray<UICollectionViewLayoutAttributes *> *unmeasuredAttrs = [NSMutableArray array]; | ||
NSMutableArray<UICollectionViewLayoutAttributes *> *unmeasuredAttrs = [[NSMutableArray alloc] init]; | ||
for (ASCollectionElement *element in table) { | ||
UICollectionViewLayoutAttributes *attrs = [table objectForKey:element]; | ||
if (element.nodeIfAllocated == nil || CGSizeEqualToSize(element.nodeIfAllocated.calculatedSize, attrs.frame.size) == NO) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ @implementation NSIndexSet (ASHelpers) | |
|
||
- (NSIndexSet *)as_indexesByMapping:(NSUInteger (^)(NSUInteger))block | ||
{ | ||
NSMutableIndexSet *result = [NSMutableIndexSet indexSet]; | ||
NSMutableIndexSet *result = [[NSMutableIndexSet alloc] init]; | ||
[self enumerateRangesUsingBlock:^(NSRange range, BOOL * _Nonnull stop) { | ||
for (NSUInteger i = range.location; i < NSMaxRange(range); i++) { | ||
NSUInteger newIndex = block(i); | ||
|
@@ -38,7 +38,7 @@ - (NSIndexSet *)as_indexesByMapping:(NSUInteger (^)(NSUInteger))block | |
|
||
- (NSIndexSet *)as_intersectionWithIndexes:(NSIndexSet *)indexes | ||
{ | ||
NSMutableIndexSet *result = [NSMutableIndexSet indexSet]; | ||
NSMutableIndexSet *result = [[NSMutableIndexSet alloc] init]; | ||
[self enumerateRangesUsingBlock:^(NSRange range, BOOL * _Nonnull stop) { | ||
[indexes enumerateRangesInRange:range options:kNilOptions usingBlock:^(NSRange range, BOOL * _Nonnull stop) { | ||
[result addIndexesInRange:range]; | ||
|
@@ -49,7 +49,7 @@ - (NSIndexSet *)as_intersectionWithIndexes:(NSIndexSet *)indexes | |
|
||
+ (NSIndexSet *)as_indexSetFromIndexPaths:(NSArray<NSIndexPath *> *)indexPaths inSection:(NSUInteger)section | ||
{ | ||
NSMutableIndexSet *result = [NSMutableIndexSet indexSet]; | ||
NSMutableIndexSet *result = [[NSMutableIndexSet alloc] init]; | ||
for (NSIndexPath *indexPath in indexPaths) { | ||
if (indexPath.section == section) { | ||
[result addIndex:indexPath.item]; | ||
|
@@ -89,22 +89,11 @@ - (NSString *)as_smallDescription | |
|
||
+ (NSIndexSet *)as_sectionsFromIndexPaths:(NSArray<NSIndexPath *> *)indexPaths | ||
{ | ||
NSMutableIndexSet *result = [NSMutableIndexSet indexSet]; | ||
NSMutableIndexSet *result = [[NSMutableIndexSet alloc] init]; | ||
for (NSIndexPath *indexPath in indexPaths) { | ||
[result addIndex:indexPath.section]; | ||
} | ||
return result; | ||
} | ||
|
||
- (NSArray<NSIndexPath *> *)as_filterIndexPathsBySection:(id<NSFastEnumeration>)indexPaths | ||
{ | ||
NSMutableArray *result = [NSMutableArray array]; | ||
for (NSIndexPath *indexPath in indexPaths) { | ||
if ([self containsIndex:indexPath.section]) { | ||
[result addObject:indexPath]; | ||
} | ||
} | ||
return result; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused |
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I was silly for putting this in in the first place. Creating autorelease pools takes a lot of time and there's absolutely no chance of anything getting added to it in here 🤦♂️