Skip to content

Commit cf5947b

Browse files
[TableGen] Avoid repeated map lookups (NFC) (#126381)
1 parent 7628fcf commit cf5947b

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

clang/utils/TableGen/ClangOptionDocEmitter.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,17 @@ Documentation extractDocumentation(const RecordKeeper &Records,
109109
// Pretend no-X and Xno-Y options are aliases of X and XY.
110110
std::string Name = std::string(R->getValueAsString("Name"));
111111
if (Name.size() >= 4) {
112-
if (Name.substr(0, 3) == "no-" && OptionsByName[Name.substr(3)]) {
113-
Aliases[OptionsByName[Name.substr(3)]].push_back(R);
114-
continue;
112+
if (Name.substr(0, 3) == "no-") {
113+
if (const Record *Opt = OptionsByName[Name.substr(3)]) {
114+
Aliases[Opt].push_back(R);
115+
continue;
116+
}
115117
}
116-
if (Name.substr(1, 3) == "no-" && OptionsByName[Name[0] + Name.substr(4)]) {
117-
Aliases[OptionsByName[Name[0] + Name.substr(4)]].push_back(R);
118-
continue;
118+
if (Name.substr(1, 3) == "no-") {
119+
if (const Record *Opt = OptionsByName[Name[0] + Name.substr(4)]) {
120+
Aliases[Opt].push_back(R);
121+
continue;
122+
}
119123
}
120124
}
121125

0 commit comments

Comments
 (0)