@@ -359,27 +359,6 @@ class ScopeCreator final {
359359 return culled;
360360 }
361361
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-
383362 SWIFT_DEBUG_DUMP { print (llvm::errs ()); }
384363
385364 void print (raw_ostream &out) const {
@@ -895,8 +874,7 @@ ASTSourceFileScope::expandAScopeThatCreatesANewInsertionPoint(
895874 std::vector<ASTNode> newNodes (decls.begin (), decls.end ());
896875 insertionPoint =
897876 scopeCreator.addSiblingsToScopeTree (insertionPoint,
898- scopeCreator.sortBySourceRange (
899- scopeCreator.cull (newNodes)),
877+ scopeCreator.cull (newNodes),
900878 endLoc);
901879
902880 // Too slow to perform all the time:
@@ -1024,9 +1002,8 @@ BraceStmtScope::expandAScopeThatCreatesANewInsertionPoint(
10241002 // elements in source order
10251003 auto *insertionPoint =
10261004 scopeCreator.addSiblingsToScopeTree (this ,
1027- scopeCreator.sortBySourceRange (
1028- scopeCreator.cull (
1029- stmt->getElements ())),
1005+ scopeCreator.cull (
1006+ stmt->getElements ()),
10301007 endLoc);
10311008 if (auto *s = scopeCreator.getASTContext ().Stats )
10321009 ++s->getFrontendCounters ().NumBraceStmtASTScopeExpansions ;
@@ -1388,7 +1365,7 @@ void GenericTypeOrExtensionScope::expandBody(ScopeCreator &) {}
13881365
13891366void IterableTypeScope::expandBody (ScopeCreator &scopeCreator) {
13901367 auto nodes = asNodeVector (getIterableDeclContext ().get ()->getMembers ());
1391- nodes = scopeCreator.sortBySourceRange (scopeCreator. cull (nodes) );
1368+ nodes = scopeCreator.cull (nodes);
13921369 scopeCreator.addSiblingsToScopeTree (this , nodes, None);
13931370 if (auto *s = scopeCreator.getASTContext ().Stats )
13941371 ++s->getFrontendCounters ().NumIterableTypeBodyASTScopeExpansions ;
0 commit comments