Skip to content

Commit

Permalink
Shrink Button Node (#1494)
Browse files Browse the repository at this point in the history
Button: 1312 to 1288 bytes, running on iPhone SE simulator. 1.9% reduction.

Shrink the enums it stores, and place them next to each other (along with a BOOL) to reduce instance size.
  • Loading branch information
Greg Bolsinga committed May 7, 2019
1 parent c571c8d commit 2fdcee8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions Source/ASButtonNode+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@
UIImage *_disabledBackgroundImage;

CGFloat _contentSpacing;
BOOL _laysOutHorizontally;
ASVerticalAlignment _contentVerticalAlignment;
ASHorizontalAlignment _contentHorizontalAlignment;
UIEdgeInsets _contentEdgeInsets;
ASButtonNodeImageAlignment _imageAlignment;
ASTextNode *_titleNode;
ASImageNode *_imageNode;
ASImageNode *_backgroundImageNode;

BOOL _laysOutHorizontally;
ASVerticalAlignment _contentVerticalAlignment;
ASHorizontalAlignment _contentHorizontalAlignment;
ASButtonNodeImageAlignment _imageAlignment;
}

@end
2 changes: 1 addition & 1 deletion Source/ASButtonNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
Image alignment defines where the image will be placed relative to the text.
*/
typedef NS_ENUM(NSInteger, ASButtonNodeImageAlignment) {
typedef NS_ENUM(unsigned char, ASButtonNodeImageAlignment) {
/** Places the image before the text. */
ASButtonNodeImageAlignmentBeginning,
/** Places the image after the text. */
Expand Down
4 changes: 2 additions & 2 deletions Source/Layout/ASStackLayoutDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ typedef NS_ENUM(NSUInteger, ASStackLayoutAlignContent) {
};

/** Orientation of children along horizontal axis */
typedef NS_ENUM(NSUInteger, ASHorizontalAlignment) {
typedef NS_ENUM(unsigned char, ASHorizontalAlignment) {
/** No alignment specified. Default value */
ASHorizontalAlignmentNone,
/** Left aligned */
Expand All @@ -128,7 +128,7 @@ typedef NS_ENUM(NSUInteger, ASHorizontalAlignment) {
};

/** Orientation of children along vertical axis */
typedef NS_ENUM(NSUInteger, ASVerticalAlignment) {
typedef NS_ENUM(unsigned char, ASVerticalAlignment) {
/** No alignment specified. Default value */
ASVerticalAlignmentNone,
/** Top aligned */
Expand Down

0 comments on commit 2fdcee8

Please sign in to comment.