Skip to content

Commit f4588d8

Browse files
committed
Speed up lookup over anonymous nested structs in class scope
Signed-off-by: Roberto Raggi <[email protected]>
1 parent 8636d9a commit f4588d8

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/parser/cxx/name_lookup.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,12 @@ auto Lookup::lookupHelper(Scope* scope, const Name* name,
144144
}
145145

146146
if (auto classSymbol = symbol_cast<ClassSymbol>(scope->owner())) {
147-
// iterate over the annonymous nested structs and unions
148-
for (auto member : classSymbol->scope()->symbols()) {
149-
if (member->name()) continue; // skip named members
150-
if (!member->isClass()) continue; // skip non-class members
147+
// iterate over the annonymous symbols
148+
for (auto member : classSymbol->scope()->find(/*unnamed=*/nullptr)) {
151149
auto nestedClass = symbol_cast<ClassSymbol>(member);
152-
auto symbol = lookupHelper(nestedClass->scope(), name, cache, accept);
150+
if (!nestedClass) continue;
153151

152+
auto symbol = lookupHelper(nestedClass->scope(), name, cache, accept);
154153
if (symbol) {
155154
// found a match in an anonymous nested class
156155
return symbol;

0 commit comments

Comments
 (0)