Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Commit 483f6eb

Browse files
committed
Address comments
1 parent 1b20117 commit 483f6eb

File tree

12 files changed

+29
-27
lines changed

12 files changed

+29
-27
lines changed

AsyncDisplayKit/ASCellNode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ typedef NS_ENUM(NSUInteger, ASCellNodeVisibilityEvent) {
7474
*/
7575
@property (nonatomic, assign) BOOL neverShowPlaceholders;
7676

77-
//TODO shouldn't this be a generic kind (e.g includes ASDataControllerRowNodeKind)?
7877
/*
7978
* The kind of supplementary element this node represents, if any.
8079
*
8180
* @return The supplementary element kind, or @c nil if this node does not represent a supplementary element.
8281
*/
82+
//TODO change this to be a generic "kind" or "elementKind" that exposes `nil` for row kind
8383
@property (nonatomic, copy, readonly, nullable) NSString *supplementaryElementKind;
8484

8585
/*

AsyncDisplayKit/ASDisplayNode+Beta.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ typedef struct {
6464
* This property defaults to NO. It will be removed in a future release.
6565
*/
6666
+ (BOOL)suppressesInvalidCollectionUpdateExceptions AS_WARN_UNUSED_RESULT ASDISPLAYNODE_DEPRECATED_MSG("Collection update exceptions are thrown if assertions are enabled.");
67-
+ (void)setSuppressesInvalidCollectionUpdateExceptions:(BOOL)suppresses ASDISPLAYNODE_DEPRECATED_MSG("Collection update exceptions are thrown if assertions are enabled.");;
67+
+ (void)setSuppressesInvalidCollectionUpdateExceptions:(BOOL)suppresses ASDISPLAYNODE_DEPRECATED_MSG("Collection update exceptions are thrown if assertions are enabled.");
6868

6969
/**
7070
* @abstract Recursively ensures node and all subnodes are displayed.

AsyncDisplayKit/Details/ASDataController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ extern NSString * const ASCollectionInvalidUpdateException;
9393
*
9494
* @param changeSet The change set that includes all updates
9595
*/
96-
- (void)dataController:(ASDataController * )dataController willUpdateWithChangeSet:(_ASHierarchyChangeSet *)changeSet;;
96+
- (void)dataController:(ASDataController *)dataController willUpdateWithChangeSet:(_ASHierarchyChangeSet *)changeSet;
9797

9898
/**
9999
* Called for change set updates.

AsyncDisplayKit/Details/ASDataController.mm

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
#import <AsyncDisplayKit/ASDisplayNode+Subclasses.h>
2626
#import <AsyncDisplayKit/NSIndexSet+ASHelpers.h>
2727

28-
#define LOG(...) NSLog(__VA_ARGS__)
29-
//#define LOG(...)
28+
//#define LOG(...) NSLog(__VA_ARGS__)
29+
#define LOG(...)
3030

3131
#define AS_MEASURE_AVOIDED_DATACONTROLLER_WORK 0
3232

@@ -144,10 +144,9 @@ + (NSUInteger)parallelProcessorCount
144144

145145
#pragma mark - Cell Layout
146146

147-
- (void)batchLayoutNodesFromContexts:(NSArray<ASIndexedNodeContext *> *)contexts batchSize:(NSUInteger)batchSize batchCompletion:(ASDataControllerCompletionBlock)batchCompletionHandler
147+
- (void)batchLayoutNodesFromContexts:(NSArray<ASIndexedNodeContext *> *)contexts batchSize:(NSInteger)batchSize batchCompletion:(ASDataControllerCompletionBlock)batchCompletionHandler
148148
{
149149
ASSERT_ON_EDITING_QUEUE;
150-
//TODO add Logs and AS_MEASURE_AVOIDED_DATACONTROLLER_WORK back
151150
#if AS_MEASURE_AVOIDED_DATACONTROLLER_WORK
152151
[ASDataController _expectToInsertNodes:contexts.count];
153152
#endif
@@ -197,19 +196,19 @@ - (void)_layoutNode:(ASCellNode *)node withConstrainedSize:(ASSizeRange)constrai
197196
}
198197

199198
__strong ASCellNode **allocatedNodeBuffer = (__strong ASCellNode **)calloc(nodeCount, sizeof(ASCellNode *));
200-
199+
201200
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
202201
ASDispatchApply(nodeCount, queue, 0, ^(size_t i) {
203202
RETURN_IF_NO_DATASOURCE();
204-
203+
205204
// Allocate the node.
206205
ASIndexedNodeContext *context = contexts[i];
207206
ASCellNode *node = context.node;
208207
if (node == nil) {
209208
ASDisplayNodeAssertNotNil(node, @"Node block created nil node; %@, %@", self, self.dataSource);
210209
node = [[ASCellNode alloc] init]; // Fallback to avoid crash for production apps.
211210
}
212-
211+
213212
// Layout the node if the size range is valid.
214213
ASSizeRange sizeRange = context.constrainedSize;
215214
if (ASSizeRangeHasSignificantArea(sizeRange)) {
@@ -221,9 +220,9 @@ - (void)_layoutNode:(ASCellNode *)node withConstrainedSize:(ASSizeRange)constrai
221220
#endif
222221
allocatedNodeBuffer[i] = node;
223222
});
224-
223+
225224
BOOL canceled = _dataSource == nil;
226-
225+
227226
// Create nodes array
228227
NSArray *nodes = canceled ? nil : [NSArray arrayWithObjects:allocatedNodeBuffer count:nodeCount];
229228

@@ -232,7 +231,7 @@ - (void)_layoutNode:(ASCellNode *)node withConstrainedSize:(ASSizeRange)constrai
232231
allocatedNodeBuffer[i] = nil;
233232
}
234233
free(allocatedNodeBuffer);
235-
234+
236235
return nodes;
237236
}
238237

@@ -289,9 +288,10 @@ - (void)_repopulateSupplementaryNodesForAllSectionsContainingIndexPaths:(NSArray
289288
// Get all the sections that need to be repopulated
290289
NSIndexSet *sectionIndexes = [NSIndexSet as_sectionsFromIndexPaths:originalIndexPaths];
291290
for (NSString *kind in [self supplementaryKindsInSections:sectionIndexes]) {
291+
// TODO: Would it make more sense to do _nodeContexts enumerateKeysAndObjectsUsingBlock: for this removal step?
292+
// That way we are sure we removed all the old supplementaries, even if that kind isn't present anymore.
293+
292294
// Step 1: Remove all existing contexts of this kind in these sections
293-
// TODO: NSEnumerationConcurrent?
294-
// TODO: Consider using a diffing algorithm here
295295
[_nodeContexts[kind] enumerateObjectsAtIndexes:sectionIndexes options:0 usingBlock:^(NSMutableArray<ASIndexedNodeContext *> * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
296296
[obj removeAllObjects];
297297
}];
@@ -409,7 +409,7 @@ - (ASSizeRange)constrainedSizeForNodeOfKind:(NSString *)kind atIndexPath:(NSInde
409409
}
410410

411411
ASDisplayNodeAssert(NO, @"Unknown constrained size for node of kind %@ by data source %@", kind, _dataSource);
412-
return ASSizeRangeMake(CGSizeZero, CGSizeZero);
412+
return ASSizeRangeZero;
413413
}
414414

415415
#pragma mark - Batching (External API)
@@ -750,10 +750,10 @@ - (NSIndexPath *)_indexPathForNode:(ASCellNode *)cellNode inContexts:(ASNodeCont
750750
if (cellNode == nil) {
751751
return nil;
752752
}
753-
753+
754754
NSString *kind = cellNode.supplementaryElementKind ?: ASDataControllerRowNodeKind;
755755
ASNodeContextTwoDimensionalArray *sections = contexts[kind];
756-
756+
757757
// Check if the cached index path is still correct.
758758
NSIndexPath *indexPath = cellNode.cachedIndexPath;
759759
if (indexPath != nil) {
@@ -765,7 +765,7 @@ - (NSIndexPath *)_indexPathForNode:(ASCellNode *)cellNode inContexts:(ASNodeCont
765765
indexPath = nil;
766766
}
767767
}
768-
768+
769769
// Loop through each section to look for the node context
770770
NSInteger sectionIdx = 0;
771771
for (NSArray<ASIndexedNodeContext *> *section in sections) {

AsyncDisplayKit/Details/ASIndexedNodeContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
2222
* property too heavily – we should remove it in the future.
2323
*/
2424
@property (nonatomic, readonly, strong) NSIndexPath *indexPath;
25-
//TODO shouldn't this be a generic kind (e.g includes ASDataControllerRowNodeKind)?
25+
//TODO change this to be a generic "kind" or "elementKind" that exposes `nil` for row kind
2626
@property (nonatomic, readonly, copy, nullable) NSString *supplementaryElementKind;
2727
@property (nonatomic, assign) ASSizeRange constrainedSize;
2828
@property (weak, nonatomic) id<ASTraitEnvironment> traitEnvironment;

AsyncDisplayKit/Details/ASRangeController.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,14 @@ AS_SUBCLASSING_RESTRICTED
152152
*
153153
* @param changeSet The change set that includes all updates
154154
*/
155-
- (void)rangeController:(ASRangeController * )rangeController willUpdateWithChangeSet:(_ASHierarchyChangeSet *)changeSet;;
155+
- (void)rangeController:(ASRangeController *)rangeController willUpdateWithChangeSet:(_ASHierarchyChangeSet *)changeSet;
156156

157157
/**
158158
* Called after updating with given change set.
159159
*
160160
* @param changeSet The change set that includes all updates
161161
*/
162-
- (void)rangeController:(ASRangeController * )rangeController didUpdateWithChangeSet:(_ASHierarchyChangeSet *)changeSet;;
162+
- (void)rangeController:(ASRangeController *)rangeController didUpdateWithChangeSet:(_ASHierarchyChangeSet *)changeSet;
163163

164164
@end
165165

AsyncDisplayKit/Details/ASTraitCollection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ ASDISPLAYNODE_EXTERN_C_END
9292
* Deprecated and should be replaced by the methods from above
9393
*/
9494
- (ASEnvironmentTraitCollection)environmentTraitCollection;
95-
- (void)setEnvironmentTraitCollection:(ASEnvironmentTraitCollection)traitCollection;;
95+
- (void)setEnvironmentTraitCollection:(ASEnvironmentTraitCollection)traitCollection;
9696

9797

9898
@end

AsyncDisplayKit/Layout/ASLayoutElement.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ ASDISPLAYNODE_EXTERN_C_END
7777
/**
7878
* @abstract Returns type of layoutElement
7979
*/
80-
@property (nonatomic, assign, readonly) ASLayoutElementType layoutElementType;;
80+
@property (nonatomic, assign, readonly) ASLayoutElementType layoutElementType;
8181

8282
/**
8383
* @abstract A size constraint that should apply to this ASLayoutElement.

AsyncDisplayKit/Private/Layout/ASStackUnpositionedLayout.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ static void computeCrossSizeAndBaseline(const std::vector<ASStackLayoutSpecItem>
183183
}
184184

185185
// Step 3. The used cross-size of the flex line is the largest of the numbers found in the previous two steps and zero.
186-
crossSize = MAX(maxStartToBaselineDistance + maxBaselineToEndDistance, maxItemCrossSize);;
186+
crossSize = MAX(maxStartToBaselineDistance + maxBaselineToEndDistance, maxItemCrossSize);
187187
// Clamp the cross-size to be within the stack's min and max cross-size properties.
188188
crossSize = MIN(MAX(minCrossSize, crossSize), maxCrossSize);
189189

AsyncDisplayKit/Private/_ASHierarchyChangeSet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ NSString *NSStringFromASHierarchyChangeType(_ASHierarchyChangeType changeType);
128128

129129
@property (nonatomic, readonly) BOOL completed;
130130
/// Whether or not changes should be animated.
131+
// TODO: if any update in this chagne set is non-animated, the whole update should be non-animated.
131132
@property (nonatomic, readwrite) BOOL animated;
132133
@property (nonatomic, readonly) BOOL includesReloadData;
133134

0 commit comments

Comments
 (0)