X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FSupport%2FSpecialCaseList.cpp;h=21e43c5e7035d536fc1cad3267dda15b06130da9;hb=540b4f6c08a089f487edad2befb7caf98c127ac5;hp=d9921ac69205bb3bdbb7fbb94fc508c0ca5772bc;hpb=3e51f754ad08cc453c5e7476bcc6e92743b68830;p=oota-llvm.git diff --git a/lib/Support/SpecialCaseList.cpp b/lib/Support/SpecialCaseList.cpp index d9921ac6920..21e43c5e703 100644 --- a/lib/Support/SpecialCaseList.cpp +++ b/lib/Support/SpecialCaseList.cpp @@ -34,10 +34,12 @@ namespace llvm { /// reason for doing so is efficiency; StringSet is much faster at matching /// literal strings than Regex. struct SpecialCaseList::Entry { - StringSet<> Strings; - Regex *RegEx; + Entry() {} + Entry(Entry &&Other) + : Strings(std::move(Other.Strings)), RegEx(std::move(Other.RegEx)) {} - Entry() : RegEx(nullptr) {} + StringSet<> Strings; + std::unique_ptr RegEx; bool match(StringRef Query) const { return Strings.count(Query) || (RegEx && RegEx->match(Query)); @@ -147,23 +149,13 @@ bool SpecialCaseList::parse(const MemoryBuffer *MB, std::string &Error) { for (StringMap::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 >::iterator I = Entries.begin(), - E = Entries.end(); - I != E; ++I) { - for (StringMap::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 {