Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Unified Diff: tools/gn/import_manager.cc

Issue 1886453002: GN: Use std::unique_ptr for owned pointers in ImportManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/import_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/import_manager.cc
diff --git a/tools/gn/import_manager.cc b/tools/gn/import_manager.cc
index 83cc09020cdafb020462b8ece9a6ff3e9f6330dd..8c57008a339168739a4f4027475cfa3a1f14fa78 100644
--- a/tools/gn/import_manager.cc
+++ b/tools/gn/import_manager.cc
@@ -4,9 +4,6 @@
#include "tools/gn/import_manager.h"
-#include <memory>
-
-#include "base/stl_util.h"
#include "tools/gn/parse_tree.h"
#include "tools/gn/scheduler.h"
#include "tools/gn/scope_per_file_provider.h"
@@ -14,10 +11,10 @@
namespace {
// Returns a newly-allocated scope on success, null on failure.
-Scope* UncachedImport(const Settings* settings,
- const SourceFile& file,
- const ParseNode* node_for_err,
- Err* err) {
+std::unique_ptr<Scope> UncachedImport(const Settings* settings,
+ const SourceFile& file,
+ const ParseNode* node_for_err,
+ Err* err) {
const ParseNode* node = g_scheduler->input_file_manager()->SyncLoadFile(
node_for_err->GetRange(), settings->build_settings(), file, err);
if (!node)
@@ -37,7 +34,7 @@ Scope* UncachedImport(const Settings* settings,
return nullptr;
scope->ClearProcessingImport();
- return scope.release();
+ return scope;
}
} // namesapce
@@ -46,7 +43,6 @@ ImportManager::ImportManager() {
}
ImportManager::~ImportManager() {
- STLDeleteContainerPairSecondPointers(imports_.begin(), imports_.end());
}
bool ImportManager::DoImport(const SourceFile& file,
@@ -60,14 +56,14 @@ bool ImportManager::DoImport(const SourceFile& file,
base::AutoLock lock(lock_);
ImportMap::const_iterator found = imports_.find(file);
if (found != imports_.end())
- imported_scope = found->second;
+ imported_scope = found->second.get();
}
if (!imported_scope) {
// Do a new import of the file.
- imported_scope = UncachedImport(scope->settings(), file,
- node_for_err, err);
- if (!imported_scope)
+ std::unique_ptr<Scope> new_imported_scope =
+ UncachedImport(scope->settings(), file, node_for_err, err);
+ if (!new_imported_scope)
return false;
// We loaded the file outside the lock. This means that there could be a
@@ -77,10 +73,10 @@ bool ImportManager::DoImport(const SourceFile& file,
base::AutoLock lock(lock_);
ImportMap::const_iterator found = imports_.find(file);
if (found != imports_.end()) {
- delete imported_scope;
- imported_scope = found->second;
+ imported_scope = found->second.get();
} else {
- imports_[file] = imported_scope;
+ imported_scope = new_imported_scope.get();
+ imports_[file] = std::move(new_imported_scope);
}
}
}
« no previous file with comments | « tools/gn/import_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698