mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-19 12:49:02 +00:00
Switch layout flatten to BFS for node ordering
This commit is contained in:
parent
c8af28e2d7
commit
184d1fc059
@ -64,7 +64,7 @@ NSInteger const ASDefaultDrawingPriority = ASDefaultTransactionPriority;
|
|||||||
|
|
||||||
BOOL ASDisplayNodeSubclassOverridesSelector(Class subclass, SEL selector)
|
BOOL ASDisplayNodeSubclassOverridesSelector(Class subclass, SEL selector)
|
||||||
{
|
{
|
||||||
return ASSubclassOverridesSelector([ASDisplayNode class], subclass, selector);
|
return ASSubclassOverridesSelector([ASDisplayNode class], subclass, selector);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASDisplayNodeRespectThreadAffinityOfNode(ASDisplayNode *node, void (^block)())
|
void ASDisplayNodeRespectThreadAffinityOfNode(ASDisplayNode *node, void (^block)())
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
#import "ASAssert.h"
|
#import "ASAssert.h"
|
||||||
#import "ASLayoutSpecUtilities.h"
|
#import "ASLayoutSpecUtilities.h"
|
||||||
#import "ASInternalHelpers.h"
|
#import "ASInternalHelpers.h"
|
||||||
#import <stack>
|
#import <queue>
|
||||||
|
|
||||||
CGPoint const CGPointNull = {NAN, NAN};
|
CGPoint const CGPointNull = {NAN, NAN};
|
||||||
|
|
||||||
@ -71,14 +71,14 @@ extern BOOL CGPointIsNull(CGPoint point)
|
|||||||
BOOL visited;
|
BOOL visited;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Stack of Contexts, used to keep track of sublayouts while traversing this layout in a DFS fashion.
|
// Stack of Contexts, used to keep track of sublayouts while traversing this layout in a BFS fashion.
|
||||||
std::stack<Context> stack;
|
std::queue<Context> queue;
|
||||||
stack.push({self, CGPointMake(0, 0), NO});
|
queue.push({self, CGPointMake(0, 0), NO});
|
||||||
|
|
||||||
while (!stack.empty()) {
|
while (!queue.empty()) {
|
||||||
Context &context = stack.top();
|
Context &context = queue.front();
|
||||||
if (context.visited) {
|
if (context.visited) {
|
||||||
stack.pop();
|
queue.pop();
|
||||||
} else {
|
} else {
|
||||||
context.visited = YES;
|
context.visited = YES;
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ extern BOOL CGPointIsNull(CGPoint point)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (ASLayout *sublayout in context.layout.sublayouts) {
|
for (ASLayout *sublayout in context.layout.sublayouts) {
|
||||||
stack.push({sublayout, context.absolutePosition + sublayout.position, NO});
|
queue.push({sublayout, context.absolutePosition + sublayout.position, NO});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user