Skip to content

Commit 2e04cc5

Browse files
committed
simplify sorting
1 parent 7b0c9ab commit 2e04cc5

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

ios/gamma/stack/host/RNSStackOperationCoordinator.mm

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -64,26 +64,14 @@ - (void)executePendingOperationsIfNeeded:(nonnull RNSStackNavigationController *
6464
[_pendingPushOperations removeAllObjects];
6565
}
6666

67-
- (NSMutableArray<id<RNSStackOperation>> *)orderedOperations:(nonnull NSMutableArray<id<RNSStackOperation>> *)operations
68-
withIndicesFrom:
69-
(nonnull NSMutableArray<RNSStackScreenComponentView *> *)stackScreens
67+
- (NSArray<id<RNSStackOperation>> *)orderedOperations:(nonnull NSMutableArray<id<RNSStackOperation>> *)operations
68+
withIndicesFrom:
69+
(nonnull NSMutableArray<RNSStackScreenComponentView *> *)stackScreens
7070
{
71-
NSMutableArray<NSDictionary *> *operationsWithIndices = [NSMutableArray array];
72-
for (id<RNSStackOperation> operation in operations) {
73-
NSInteger index = [stackScreens indexOfObject:operation.stackScreen];
74-
[operationsWithIndices addObject:@{@"index" : @(index), @"operation" : operation}];
75-
}
76-
77-
[operationsWithIndices sortUsingComparator:^NSComparisonResult(NSDictionary *obj1, NSDictionary *obj2) {
78-
return [obj1[@"index"] compare:obj2[@"index"]];
71+
return [operations sortedArrayUsingComparator:^NSComparisonResult(id<RNSStackOperation> obj1,
72+
id<RNSStackOperation> obj2) {
73+
return [@([stackScreens indexOfObject:obj1.stackScreen]) compare:@([stackScreens indexOfObject:obj2.stackScreen])];
7974
}];
80-
81-
NSMutableArray<id<RNSStackOperation>> *orderedOperations = [NSMutableArray new];
82-
for (NSDictionary *dict in operationsWithIndices) {
83-
[orderedOperations addObject:dict[@"operation"]];
84-
}
85-
86-
return orderedOperations;
8775
}
8876

8977
@end

0 commit comments

Comments
 (0)