Skip to content

Commit

Permalink
Shrink Pager and Scroll Node (#1496)
Browse files Browse the repository at this point in the history
Running on iPhone SE Simulator:
ASPagerNode 1240 to 1232 bytes .7% reduction
ASScrollNode 1104 to 1096 bytes .7% reduction

- make ASScrollNode smaller by shrinking ASScrollDirection, which requires a change to ASRangeController
- shrink ASPagerNode by declaring the BOOL next to the struct
  • Loading branch information
Greg Bolsinga authored May 7, 2019
1 parent 3374706 commit 8b70b76
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
1 change: 1 addition & 0 deletions Source/ASPagerNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ @interface ASPagerNode () <ASCollectionDataSource, ASCollectionDelegate, ASColle
unsigned nodeBlockAtIndex:1;
unsigned nodeAtIndex:1;
} _pagerDataSourceFlags;
BOOL _allowsAutomaticInsetsAdjustment;

__weak id <ASPagerDelegate> _pagerDelegate;
ASPagerNodeProxy *_proxyDelegate;
Expand Down
6 changes: 2 additions & 4 deletions Source/Details/ASRangeController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#import <AsyncDisplayKit/ASAssert.h>
#import <AsyncDisplayKit/ASCellNode+Internal.h>
#import <AsyncDisplayKit/ASCollectionElement.h>
#import <AsyncDisplayKit/ASCollectionView.h>
#import <AsyncDisplayKit/ASDisplayNodeExtras.h>
#import <AsyncDisplayKit/ASDisplayNodeInternal.h> // Required for interfaceState and hierarchyState setter methods.
#import <AsyncDisplayKit/ASElementMap.h>
Expand Down Expand Up @@ -397,10 +398,7 @@ - (void)_updateVisibleNodeIndexPaths
if (ASDisplayNode.shouldShowRangeDebugOverlay) {
ASScrollDirection scrollableDirections = ASScrollDirectionUp | ASScrollDirectionDown;
if ([_dataSource isKindOfClass:NSClassFromString(@"ASCollectionView")]) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundeclared-selector"
scrollableDirections = (ASScrollDirection)[_dataSource performSelector:@selector(scrollableDirections)];
#pragma clang diagnostic pop
scrollableDirections = ((ASCollectionView *)_dataSource).scrollableDirections;
}

[self updateRangeController:self
Expand Down
2 changes: 1 addition & 1 deletion Source/Details/ASScrollDirection.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

NS_ASSUME_NONNULL_BEGIN

typedef NS_OPTIONS(NSInteger, ASScrollDirection) {
typedef NS_OPTIONS(unsigned char, ASScrollDirection) {
ASScrollDirectionNone = 0,
ASScrollDirectionRight = 1 << 0,
ASScrollDirectionLeft = 1 << 1,
Expand Down

0 comments on commit 8b70b76

Please sign in to comment.