Skip to content

Commit

Permalink
Make sure all ASDisplayNode properties have backing ivars for consist…
Browse files Browse the repository at this point in the history
…ency. (#1475)

* Make sure all ASDisplayNodes have backing ivars for consistency.

Found this by enabling #pragma clang diagnostic error "-Wobjc-missing-property-synthesis" for ASDisplayNode. One property is unused, saving 8 bytes of heap space per instance on 64-bit builds. Implement setter/getters for these properties, and add appropriate locking. add the warning as error to the build for this file.
  • Loading branch information
Greg Bolsinga authored Apr 30, 2019
1 parent 15fb7e0 commit d6061f4
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 14 deletions.
5 changes: 5 additions & 0 deletions Source/ASDisplayNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#import <AsyncDisplayKit/ASLayoutElement.h>
#import <AsyncDisplayKit/ASLocking.h>

#pragma clang diagnostic push
#pragma clang diagnostic error "-Wobjc-missing-property-synthesis"

NS_ASSUME_NONNULL_BEGIN

#define ASDisplayNodeLoggingEnabled 0
Expand Down Expand Up @@ -987,3 +990,5 @@ typedef NS_ENUM(NSInteger, ASLayoutEngineType) {
@end

NS_ASSUME_NONNULL_END

#pragma clang diagnostic pop
36 changes: 36 additions & 0 deletions Source/ASDisplayNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2635,6 +2635,42 @@ - (BOOL)placeholderShouldPersist
return NO;
}

- (BOOL)placeholderEnabled
{
MutexLocker l(__instanceLock__);
return _placeholderEnabled;
}

- (void)setPlaceholderEnabled:(BOOL)placeholderEnabled
{
MutexLocker l(__instanceLock__);
_placeholderEnabled = placeholderEnabled;
}

- (NSTimeInterval)placeholderFadeDuration
{
MutexLocker l(__instanceLock__);
return _placeholderFadeDuration;
}

- (void)setPlaceholderFadeDuration:(NSTimeInterval)placeholderFadeDuration
{
MutexLocker l(__instanceLock__);
_placeholderFadeDuration = placeholderFadeDuration;
}

- (NSInteger)drawingPriority
{
MutexLocker l(__instanceLock__);
return _drawingPriority;
}

- (void)setDrawingPriority:(NSInteger)drawingPriority
{
MutexLocker l(__instanceLock__);
_drawingPriority = drawingPriority;
}

#pragma mark - Hierarchy State

- (BOOL)isInHierarchy
Expand Down
17 changes: 3 additions & 14 deletions Source/Private/ASDisplayNodeInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ static constexpr CACornerMask kASCACornerAllCorners =
UIImage *_placeholderImage;
BOOL _placeholderEnabled;
CALayer *_placeholderLayer;
NSTimeInterval _placeholderFadeDuration;

NSInteger _drawingPriority;

// keeps track of nodes/subnodes that have not finished display, used with placeholders
ASWeakSet *_pendingDisplayNodes;
Expand Down Expand Up @@ -351,20 +354,6 @@ static constexpr CACornerMask kASCACornerAllCorners =
*/
- (void)enumerateInterfaceStateDelegates:(void(NS_NOESCAPE ^)(id<ASInterfaceStateDelegate> delegate))block;

/**
* // TODO: NOT YET IMPLEMENTED
*
* @abstract Prevents interface state changes from affecting the node, until disabled.
*
* @discussion Useful to avoid flashing after removing a node from the hierarchy and re-adding it.
* Removing a node from the hierarchy will cause it to exit the Display state, clearing its contents.
* For some animations, it's desirable to be able to remove a node without causing it to re-display.
* Once re-enabled, the interface state will be updated to the same value it would have been.
*
* @see ASInterfaceState
*/
@property (nonatomic) BOOL interfaceStateSuspended;

/**
* This method has proven helpful in a few rare scenarios, similar to a category extension on UIView,
* but it's considered private API for now and its use should not be encouraged.
Expand Down

0 comments on commit d6061f4

Please sign in to comment.