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); |
} |
} |
} |