Skip to content

Commit 7a59990

Browse files
committed
Improve unclear and unnecessarily long code
1 parent 797ad11 commit 7a59990

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

llvm/lib/Support/ELFAttrParserExtended.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,9 @@ StringRef
5151
ELFExtendedAttrParser::getTagName(const StringRef &BuildAttrSubsectionName,
5252
const unsigned Tag) {
5353
for (const auto &Entry : TagsNamesMap) {
54-
if (BuildAttrSubsectionName == Entry.SubsectionName) {
55-
if (Tag == Entry.Tag) {
54+
if (BuildAttrSubsectionName == Entry.SubsectionName)
55+
if (Tag == Entry.Tag)
5656
return Entry.TagName;
57-
}
58-
}
5957
}
6058
return "";
6159
}
@@ -136,23 +134,21 @@ Error ELFExtendedAttrParser::parse(ArrayRef<uint8_t> Section,
136134
(OffsetInSection + ExtBASubsectionLength - BytesAllButAttributes)) {
137135

138136
uint64_t Tag = De.getULEB128(Cursor);
139-
std::string Str = utostr(Tag);
140-
StringRef TagStr(Str);
141137

142-
StringRef TagAsString = getTagName(VendorName, Tag);
143-
if ("" != TagAsString)
144-
TagStr = TagAsString;
138+
StringRef TagName = getTagName(VendorName, Tag);
139+
if ("" == TagName)
140+
TagName = StringRef(utostr(Tag));
145141

146142
uint64_t ValueInt = 0;
147143
std::string ValueStr = "";
148144
if (Type) { // type==1 --> ntbs
149145
StringRef Value = De.getCStrRef(Cursor);
150146
if (Sw)
151-
Sw->printString(TagStr, Value);
147+
Sw->printString(TagName, Value);
152148
} else { // type==0 --> uleb128
153149
uint64_t Value = De.getULEB128(Cursor);
154150
if (Sw)
155-
Sw->printNumber(TagStr, Value);
151+
Sw->printNumber(TagName, Value);
156152
}
157153

158154
// populate data structure

0 commit comments

Comments
 (0)