From: Peter Collingbourne Date: Thu, 10 Jul 2014 03:55:02 +0000 (+0000) Subject: SpecialCaseList: use std::unique_ptr. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=0f29cefbc253b85272e78595053607ff9206202b;p=oota-llvm.git SpecialCaseList: use std::unique_ptr. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212678 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Support/SpecialCaseList.cpp b/lib/Support/SpecialCaseList.cpp index d9921ac6920..a81ba23ff6d 100644 --- a/lib/Support/SpecialCaseList.cpp +++ b/lib/Support/SpecialCaseList.cpp @@ -35,9 +35,7 @@ namespace llvm { /// literal strings than Regex. struct SpecialCaseList::Entry { StringSet<> Strings; - Regex *RegEx; - - Entry() : RegEx(nullptr) {} + std::unique_ptr RegEx; bool match(StringRef Query) const { return Strings.count(Query) || (RegEx && RegEx->match(Query)); @@ -147,23 +145,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 {