Prefer unique_ptr<> and make_xxxx over raw pointers and new.

There doesn't seem to be any reason to use a raw pointer for the
IRGenerator.

Change-Id: I5a37ff8ee212534dc8357722aaf70637623840bb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/313720
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
John Stiles 2020-08-27 15:26:26 -04:00 committed by Skia Commit-Bot
parent 638b2e8594
commit 656427a553
2 changed files with 4 additions and 6 deletions

View File

@ -104,8 +104,8 @@ Compiler::Compiler(Flags flags)
, fFlags(flags)
, fContext(std::make_shared<Context>())
, fErrorCount(0) {
auto symbols = std::shared_ptr<SymbolTable>(new SymbolTable(this));
fIRGenerator = new IRGenerator(fContext.get(), symbols, *this);
auto symbols = std::make_shared<SymbolTable>(this);
fIRGenerator = std::make_unique<IRGenerator>(fContext.get(), symbols, *this);
#define ADD_TYPE(t) symbols->addWithoutOwnership(fContext->f ## t ## _Type->fName, \
fContext->f ## t ## _Type.get())
ADD_TYPE(Void);
@ -272,9 +272,7 @@ Compiler::Compiler(Flags flags)
grab_intrinsics(&interpIntrinsics, fInterpreterIntrinsics.get());
}
Compiler::~Compiler() {
delete fIRGenerator;
}
Compiler::~Compiler() {}
void Compiler::loadGeometryIntrinsics() {
if (fGeometrySymbolTable) {

View File

@ -241,7 +241,7 @@ private:
std::vector<std::unique_ptr<ProgramElement>> fFPInclude;
std::shared_ptr<SymbolTable> fFPSymbolTable;
IRGenerator* fIRGenerator;
std::unique_ptr<IRGenerator> fIRGenerator;
int fFlags;
const String* fSource;