From d5feb7ba426e9bb845951ab71b1065cd11e01a53 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 10 Jul 2014 03:55:02 +0000 Subject: [PATCH] SpecialCaseList: use std::unique_ptr. llvm-svn: 212678 --- llvm/lib/Support/SpecialCaseList.cpp | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/llvm/lib/Support/SpecialCaseList.cpp b/llvm/lib/Support/SpecialCaseList.cpp index d9921ac..a81ba23 100644 --- a/llvm/lib/Support/SpecialCaseList.cpp +++ b/llvm/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 { -- 2.7.4