[llvm] r212678 - SpecialCaseList: use std::unique_ptr.
Peter Collingbourne
peter at pcc.me.uk
Wed Jul 9 22:25:59 PDT 2014
On Wed, Jul 09, 2014 at 10:11:18PM -0700, David Blaikie wrote:
> On Wed, Jul 9, 2014 at 8:55 PM, Peter Collingbourne <peter at pcc.me.uk> wrote:
> > 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()));
>
> I'd personally favor "= make_unique<T>" rather than ".reset(new T".
> It'd be nice if we could move towards a future in which raw 'new' is
> treated with suspicion.
I have more changes in the pipeline for this class; I'll take care of that
when I make those changes.
Thanks,
--
Peter
More information about the llvm-commits
mailing list