mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-16 11:20:18 +00:00
I don't believe it's safe to return a vector by reference created in a function. (#2286)
This commit is contained in:
parent
29dd3ce6d6
commit
d909a8af01
@ -130,16 +130,16 @@ static inline BOOL ASLayoutCanTransitionAsynchronous(ASLayout *layout) {
|
||||
compareBlock:^BOOL(ASLayout *lhs, ASLayout *rhs) {
|
||||
return ASObjectIsEqual(lhs.layoutable, rhs.layoutable);
|
||||
}];
|
||||
findNodesInLayoutAtIndexes(pendingLayout, insertions, &_insertedSubnodes, &_insertedSubnodePositions);
|
||||
findNodesInLayoutAtIndexesWithFilteredNodes(previousLayout,
|
||||
_insertedSubnodePositions = findNodesInLayoutAtIndexes(pendingLayout, insertions, &_insertedSubnodes);
|
||||
_removedSubnodePositions = findNodesInLayoutAtIndexesWithFilteredNodes(previousLayout,
|
||||
deletions,
|
||||
_insertedSubnodes,
|
||||
&_removedSubnodes,
|
||||
&_removedSubnodePositions);
|
||||
&_removedSubnodes);
|
||||
} else {
|
||||
NSIndexSet *indexes = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [pendingLayout.sublayouts count])];
|
||||
findNodesInLayoutAtIndexes(pendingLayout, indexes, &_insertedSubnodes, &_insertedSubnodePositions);
|
||||
_insertedSubnodePositions = findNodesInLayoutAtIndexes(pendingLayout, indexes, &_insertedSubnodes);
|
||||
_removedSubnodes = nil;
|
||||
_removedSubnodePositions.clear();
|
||||
}
|
||||
_calculatedSubnodeOperations = YES;
|
||||
}
|
||||
@ -195,26 +195,25 @@ static inline BOOL ASLayoutCanTransitionAsynchronous(ASLayout *layout) {
|
||||
/**
|
||||
* @abstract Stores the nodes at the given indexes in the `storedNodes` array, storing indexes in a `storedPositions` c++ vector.
|
||||
*/
|
||||
static inline void findNodesInLayoutAtIndexes(ASLayout *layout,
|
||||
static inline std::vector<NSUInteger> findNodesInLayoutAtIndexes(ASLayout *layout,
|
||||
NSIndexSet *indexes,
|
||||
NSArray<ASDisplayNode *> * __strong *storedNodes,
|
||||
std::vector<NSUInteger> *storedPositions)
|
||||
NSArray<ASDisplayNode *> * __strong *storedNodes)
|
||||
{
|
||||
findNodesInLayoutAtIndexesWithFilteredNodes(layout, indexes, nil, storedNodes, storedPositions);
|
||||
return findNodesInLayoutAtIndexesWithFilteredNodes(layout, indexes, nil, storedNodes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @abstract Stores the nodes at the given indexes in the `storedNodes` array, storing indexes in a `storedPositions` c++ vector.
|
||||
* @discussion If the node exists in the `filteredNodes` array, the node is not added to `storedNodes`.
|
||||
*/
|
||||
static inline void findNodesInLayoutAtIndexesWithFilteredNodes(ASLayout *layout,
|
||||
static inline std::vector<NSUInteger> findNodesInLayoutAtIndexesWithFilteredNodes(ASLayout *layout,
|
||||
NSIndexSet *indexes,
|
||||
NSArray<ASDisplayNode *> *filteredNodes,
|
||||
NSArray<ASDisplayNode *> * __strong *storedNodes,
|
||||
std::vector<NSUInteger> *storedPositions)
|
||||
NSArray<ASDisplayNode *> * __strong *storedNodes)
|
||||
{
|
||||
NSMutableArray<ASDisplayNode *> *nodes = [NSMutableArray arrayWithCapacity:indexes.count];
|
||||
std::vector<NSUInteger> positions = std::vector<NSUInteger>();
|
||||
|
||||
// From inspection, this is how enumerateObjectsAtIndexes: works under the hood
|
||||
NSUInteger firstIndex = indexes.firstIndex;
|
||||
NSUInteger lastIndex = indexes.lastIndex;
|
||||
@ -236,7 +235,8 @@ static inline void findNodesInLayoutAtIndexesWithFilteredNodes(ASLayout *layout,
|
||||
idx += 1;
|
||||
}
|
||||
*storedNodes = nodes;
|
||||
*storedPositions = positions;
|
||||
|
||||
return positions;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user