[llvm] r212678 - SpecialCaseList: use std::unique_ptr.
Peter Collingbourne
peter at pcc.me.uk
Wed Jul 9 20:55:02 PDT 2014
Author: pcc
Date: Wed Jul 9 22:55:02 2014
New Revision: 212678
URL: http://llvm.org/viewvc/llvm-project?rev=212678&view=rev
Log:
SpecialCaseList: use std::unique_ptr.
Modified:
llvm/trunk/lib/Support/SpecialCaseList.cpp
Modified: llvm/trunk/lib/Support/SpecialCaseList.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/SpecialCaseList.cpp?rev=212678&r1=212677&r2=212678&view=diff
==============================================================================
--- llvm/trunk/lib/Support/SpecialCaseList.cpp (original)
+++ llvm/trunk/lib/Support/SpecialCaseList.cpp Wed Jul 9 22:55:02 2014
@@ -35,9 +35,7 @@ namespace llvm {
/// literal strings than Regex.
struct SpecialCaseList::Entry {
StringSet<> Strings;
- Regex *RegEx;
-
- Entry() : RegEx(nullptr) {}
+ std::unique_ptr<Regex> RegEx;
bool match(StringRef Query) const {
return Strings.count(Query) || (RegEx && RegEx->match(Query));
@@ -147,23 +145,13 @@ bool SpecialCaseList::parse(const Memory
for (StringMap<std::string>::const_iterator II = I->second.begin(),
IE = I->second.end();
II != IE; ++II) {
- Entries[I->getKey()][II->getKey()].RegEx = new Regex(II->getValue());
+ Entries[I->getKey()][II->getKey()].RegEx.reset(new Regex(II->getValue()));
}
}
return true;
}
-SpecialCaseList::~SpecialCaseList() {
- for (StringMap<StringMap<Entry> >::iterator I = Entries.begin(),
- E = Entries.end();
- I != E; ++I) {
- for (StringMap<Entry>::const_iterator II = I->second.begin(),
- IE = I->second.end();
- II != IE; ++II) {
- delete II->second.RegEx;
- }
- }
-}
+SpecialCaseList::~SpecialCaseList() {}
bool SpecialCaseList::inSection(const StringRef Section, const StringRef Query,
const StringRef Category) const {
More information about the llvm-commits
mailing list