mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Merge pull request #1930 from maicki/MSSmallCodeImprovement
[Followup] Small code improvements
This commit is contained in:
@@ -793,12 +793,7 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
||||
});
|
||||
};
|
||||
|
||||
// TODO ihm: Can we always push the measure to the background thread and remove the parameter from the API?
|
||||
if (ASDisplayNodeThreadIsMain()) {
|
||||
ASPerformBlockOnBackgroundThread(transitionBlock);
|
||||
} else {
|
||||
transitionBlock();
|
||||
}
|
||||
ASPerformBlockOnBackgroundThread(transitionBlock);
|
||||
}
|
||||
|
||||
- (void)_completeLayoutCalculation
|
||||
@@ -1140,9 +1135,19 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
||||
|
||||
- (void)measureNodeWithBoundsIfNecessary:(CGRect)bounds
|
||||
{
|
||||
BOOL supportsRangedManagedInterfaceState = NO;
|
||||
BOOL hasDirtyLayout = NO;
|
||||
BOOL hasSupernode = NO;
|
||||
{
|
||||
ASDN::MutexLocker l(_propertyLock);
|
||||
supportsRangedManagedInterfaceState = [self supportsRangeManagedInterfaceState];
|
||||
hasDirtyLayout = [self _hasDirtyLayout];
|
||||
hasSupernode = (self.supernode != nil);
|
||||
}
|
||||
|
||||
// Normally measure will be called before layout occurs. If this doesn't happen, nothing is going to call it at all.
|
||||
// We simply call measureWithSizeRange: using a size range equal to whatever bounds were provided to that element
|
||||
if (self.supernode == nil && !self.supportsRangeManagedInterfaceState && [self _hasDirtyLayout]) {
|
||||
if (!hasSupernode && !supportsRangedManagedInterfaceState && hasDirtyLayout) {
|
||||
if (CGRectEqualToRect(bounds, CGRectZero)) {
|
||||
LOG(@"Warning: No size given for node before node was trying to layout itself: %@. Please provide a frame for the node.", self);
|
||||
} else {
|
||||
@@ -2744,7 +2749,7 @@ static void _recursivelySetDisplaySuspended(ASDisplayNode *node, CALayer *layer,
|
||||
return _flags.shouldAnimateSizeChanges;
|
||||
}
|
||||
|
||||
-(void)setShouldAnimateSizeChanges:(BOOL)shouldAnimateSizeChanges
|
||||
- (void)setShouldAnimateSizeChanges:(BOOL)shouldAnimateSizeChanges
|
||||
{
|
||||
ASDisplayNodeAssertThreadAffinity(self);
|
||||
ASDN::MutexLocker l(_propertyLock);
|
||||
@@ -2766,7 +2771,7 @@ static const char *ASDisplayNodeDrawingPriorityKey = "ASDrawingPriority";
|
||||
}
|
||||
}
|
||||
|
||||
-(NSInteger)drawingPriority
|
||||
- (NSInteger)drawingPriority
|
||||
{
|
||||
ASDisplayNodeAssertThreadAffinity(self);
|
||||
ASDN::MutexLocker l(_propertyLock);
|
||||
|
||||
@@ -165,8 +165,7 @@ NSString * const ASDataControllerRowNodeKind = @"_ASDataControllerRowNodeKind";
|
||||
return;
|
||||
}
|
||||
|
||||
// Layout node on whatever thread we are on. We handle the trampoline to the main thread in case the node is
|
||||
// already loaded
|
||||
// Layout nodes based on the given context constrained size
|
||||
for (NSUInteger k = range.location; k < NSMaxRange(range); k++) {
|
||||
ASCellNode *node = nodes[k];
|
||||
ASIndexedNodeContext *context = contexts[k];
|
||||
|
||||
Reference in New Issue
Block a user