@@ -359,27 +359,6 @@ class ScopeCreator final {
359
359
return culled;
360
360
}
361
361
362
- // / Templated to work on either ASTNodes, Decl*'s, or whatnot.
363
- template <typename Rangeable>
364
- std::vector<Rangeable>
365
- sortBySourceRange (std::vector<Rangeable> toBeSorted) const {
366
- auto compareNodes = [&](Rangeable n1, Rangeable n2) {
367
- return isNotAfter (n1, n2);
368
- };
369
- std::stable_sort (toBeSorted.begin (), toBeSorted.end (), compareNodes);
370
- return toBeSorted;
371
- }
372
-
373
- template <typename Rangeable>
374
- bool isNotAfter (Rangeable n1, Rangeable n2) const {
375
- const auto r1 = getRangeableSourceRange (n1);
376
- const auto r2 = getRangeableSourceRange (n2);
377
-
378
- const int signum = ASTScopeImpl::compare (r1, r2, ctx.SourceMgr ,
379
- /* ensureDisjoint=*/ true );
380
- return -1 == signum;
381
- }
382
-
383
362
SWIFT_DEBUG_DUMP { print (llvm::errs ()); }
384
363
385
364
void print (raw_ostream &out) const {
@@ -895,8 +874,7 @@ ASTSourceFileScope::expandAScopeThatCreatesANewInsertionPoint(
895
874
std::vector<ASTNode> newNodes (decls.begin (), decls.end ());
896
875
insertionPoint =
897
876
scopeCreator.addSiblingsToScopeTree (insertionPoint,
898
- scopeCreator.sortBySourceRange (
899
- scopeCreator.cull (newNodes)),
877
+ scopeCreator.cull (newNodes),
900
878
endLoc);
901
879
902
880
// Too slow to perform all the time:
@@ -1024,9 +1002,8 @@ BraceStmtScope::expandAScopeThatCreatesANewInsertionPoint(
1024
1002
// elements in source order
1025
1003
auto *insertionPoint =
1026
1004
scopeCreator.addSiblingsToScopeTree (this ,
1027
- scopeCreator.sortBySourceRange (
1028
- scopeCreator.cull (
1029
- stmt->getElements ())),
1005
+ scopeCreator.cull (
1006
+ stmt->getElements ()),
1030
1007
endLoc);
1031
1008
if (auto *s = scopeCreator.getASTContext ().Stats )
1032
1009
++s->getFrontendCounters ().NumBraceStmtASTScopeExpansions ;
@@ -1388,7 +1365,7 @@ void GenericTypeOrExtensionScope::expandBody(ScopeCreator &) {}
1388
1365
1389
1366
void IterableTypeScope::expandBody (ScopeCreator &scopeCreator) {
1390
1367
auto nodes = asNodeVector (getIterableDeclContext ().get ()->getMembers ());
1391
- nodes = scopeCreator.sortBySourceRange (scopeCreator. cull (nodes) );
1368
+ nodes = scopeCreator.cull (nodes);
1392
1369
scopeCreator.addSiblingsToScopeTree (this , nodes, None);
1393
1370
if (auto *s = scopeCreator.getASTContext ().Stats )
1394
1371
++s->getFrontendCounters ().NumIterableTypeBodyASTScopeExpansions ;
0 commit comments