Skip to content

Commit 2677c29

Browse files
vitalybukaarsenm
andauthored
[NFC][SpecialCaseList] Store SectionStr as StringRef (#167278)
The SectionStr is already copied in addSection, so there is no need to copy it again in the Section constructor. Co-authored-by: Matt Arsenault <[email protected]>
1 parent 0e639ae commit 2677c29

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

llvm/include/llvm/Support/SpecialCaseList.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ class SpecialCaseList {
232232
findMatcher(StringRef Prefix, StringRef Category) const;
233233

234234
Matcher SectionMatcher;
235-
std::string SectionStr;
235+
StringRef SectionStr;
236236
SectionEntries Entries;
237237
unsigned FileIdx;
238238
};

llvm/lib/Support/SpecialCaseList.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,10 @@ bool SpecialCaseList::createInternal(const MemoryBuffer *MB, std::string &Error,
243243
Expected<SpecialCaseList::Section *>
244244
SpecialCaseList::addSection(StringRef SectionStr, unsigned FileNo,
245245
unsigned LineNo, bool UseGlobs) {
246+
SectionStr = SectionStr.copy(StrAlloc);
246247
Sections.emplace_back(SectionStr, FileNo, UseGlobs);
247248
auto &Section = Sections.back();
248249

249-
SectionStr = SectionStr.copy(StrAlloc);
250250
if (auto Err = Section.SectionMatcher.insert(SectionStr, LineNo)) {
251251
return createStringError(errc::invalid_argument,
252252
"malformed section at line " + Twine(LineNo) +

0 commit comments

Comments
 (0)