|
30 | 30 | #include "swift/AST/TypeRepr.h"
|
31 | 31 | #include "swift/Basic/STLExtras.h"
|
32 | 32 | #include "llvm/Support/Compiler.h"
|
33 |
| -#include <algorithm> |
34 | 33 |
|
35 | 34 | using namespace swift;
|
36 | 35 | using namespace namelookup;
|
@@ -170,22 +169,15 @@ NullablePtr<ASTScopeImpl>
|
170 | 169 | ASTScopeImpl::findChildContaining(SourceLoc loc,
|
171 | 170 | SourceManager &sourceMgr) const {
|
172 | 171 | // Use binary search to find the child that contains this location.
|
173 |
| - struct CompareLocs { |
174 |
| - SourceManager &sourceMgr; |
175 |
| - |
176 |
| - bool operator()(const ASTScopeImpl *scope, SourceLoc loc) { |
177 |
| - ASTScopeAssert(scope->checkSourceRangeOfThisASTNode(), "Bad range."); |
178 |
| - auto rangeOfScope = scope->getSourceRangeOfScope(); |
179 |
| - loc = translateLocForReplacedRange(sourceMgr, rangeOfScope, loc); |
180 |
| - return -1 == ASTScopeImpl::compare(rangeOfScope, loc, sourceMgr, |
181 |
| - /*ensureDisjoint=*/false); |
182 |
| - } |
183 |
| - bool operator()(SourceLoc loc, const ASTScopeImpl *scope) { |
184 |
| - return !(*this)(scope, loc); |
185 |
| - } |
186 |
| - }; |
187 |
| - auto *const *child = std::lower_bound( |
188 |
| - getChildren().begin(), getChildren().end(), loc, CompareLocs{sourceMgr}); |
| 172 | + auto *const *child = llvm::lower_bound( |
| 173 | + getChildren(), loc, |
| 174 | + [&sourceMgr](const ASTScopeImpl *scope, SourceLoc loc) { |
| 175 | + ASTScopeAssert(scope->checkSourceRangeOfThisASTNode(), "Bad range."); |
| 176 | + auto rangeOfScope = scope->getSourceRangeOfScope(); |
| 177 | + loc = translateLocForReplacedRange(sourceMgr, rangeOfScope, loc); |
| 178 | + return -1 == ASTScopeImpl::compare(rangeOfScope, loc, sourceMgr, |
| 179 | + /*ensureDisjoint=*/false); |
| 180 | + }); |
189 | 181 |
|
190 | 182 | if (child != getChildren().end()) {
|
191 | 183 | auto rangeOfScope = (*child)->getSourceRangeOfScope();
|
|
0 commit comments