Skip to content

Commit b982693

Browse files
committed
[Sema] NFC: Simplify some filtering logic
1 parent 5004159 commit b982693

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

lib/Sema/TypeCheckDeclObjC.cpp

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,24 +1940,13 @@ static AbstractFunctionDecl *lookupObjCMethodInClass(
19401940
if (!methods.empty()) {
19411941
// If we aren't inheriting initializers, remove any initializers from the
19421942
// list.
1943-
if (!inheritingInits &&
1944-
std::find_if(methods.begin(), methods.end(),
1945-
[](AbstractFunctionDecl *func) {
1946-
return isa<ConstructorDecl>(func);
1947-
}) != methods.end()) {
1948-
SmallVector<AbstractFunctionDecl *, 4> nonInitMethods;
1949-
std::copy_if(methods.begin(), methods.end(),
1950-
std::back_inserter(nonInitMethods),
1951-
[&](AbstractFunctionDecl *func) {
1952-
return !isa<ConstructorDecl>(func);
1953-
});
1954-
if (nonInitMethods.empty())
1943+
if (!inheritingInits) {
1944+
llvm::erase_if(methods, [](AbstractFunctionDecl *afd) {
1945+
return isa<ConstructorDecl>(afd);
1946+
});
1947+
if (methods.empty())
19551948
return nullptr;
1956-
1957-
return *std::min_element(nonInitMethods.begin(), nonInitMethods.end(),
1958-
OrderDeclarations(srcMgr));
19591949
}
1960-
19611950
return *std::min_element(methods.begin(), methods.end(),
19621951
OrderDeclarations(srcMgr));
19631952
}

0 commit comments

Comments
 (0)