Commit 048019f3 authored by dcheng's avatar dcheng Committed by Commit bot

Simplify ScopedVector<scoped_ptr<T>> to ScopedVector<T>.

Also removes a couple more PassAs() calls.

BUG=423621

Review URL: https://codereview.chromium.org/654263004

Cr-Commit-Position: refs/heads/master@{#300129}
parent 923ac874
...@@ -92,8 +92,7 @@ Value RunGetTargetOutputs(Scope* scope, ...@@ -92,8 +92,7 @@ Value RunGetTargetOutputs(Scope* scope,
*err = Err(function, "No targets defined in this context."); *err = Err(function, "No targets defined in this context.");
return Value(); return Value();
} }
for (const auto& cur : *collector) { for (const auto& item : *collector) {
const Item* item = cur->get();
if (item->label() != label) if (item->label() != label)
continue; continue;
......
...@@ -65,7 +65,7 @@ TEST_F(GetTargetOutputsTest, Copy) { ...@@ -65,7 +65,7 @@ TEST_F(GetTargetOutputsTest, Copy) {
action->action_values().outputs() = action->action_values().outputs() =
SubstitutionList::MakeForTest("//out/Debug/{{source_file_part}}.one"); SubstitutionList::MakeForTest("//out/Debug/{{source_file_part}}.one");
items_.push_back(new scoped_ptr<Item>(action)); items_.push_back(action);
Err err; Err err;
Value result = GetTargetOutputs("//foo:bar", &err); Value result = GetTargetOutputs("//foo:bar", &err);
...@@ -80,7 +80,7 @@ TEST_F(GetTargetOutputsTest, Action) { ...@@ -80,7 +80,7 @@ TEST_F(GetTargetOutputsTest, Action) {
"//output1.txt", "//output1.txt",
"//output2.txt"); "//output2.txt");
items_.push_back(new scoped_ptr<Item>(action)); items_.push_back(action);
Err err; Err err;
Value result = GetTargetOutputs("//foo:bar", &err); Value result = GetTargetOutputs("//foo:bar", &err);
...@@ -96,7 +96,7 @@ TEST_F(GetTargetOutputsTest, ActionForeach) { ...@@ -96,7 +96,7 @@ TEST_F(GetTargetOutputsTest, ActionForeach) {
"//out/Debug/{{source_file_part}}.one", "//out/Debug/{{source_file_part}}.one",
"//out/Debug/{{source_file_part}}.two"); "//out/Debug/{{source_file_part}}.two");
items_.push_back(new scoped_ptr<Item>(action)); items_.push_back(action);
Err err; Err err;
Value result = GetTargetOutputs("//foo:bar", &err); Value result = GetTargetOutputs("//foo:bar", &err);
......
...@@ -342,7 +342,7 @@ Value RunToolchain(Scope* scope, ...@@ -342,7 +342,7 @@ Value RunToolchain(Scope* scope,
*err = Err(function, "Can't define a toolchain in this context."); *err = Err(function, "Can't define a toolchain in this context.");
return Value(); return Value();
} }
collector->push_back(new scoped_ptr<Item>(toolchain.PassAs<Item>())); collector->push_back(toolchain.release());
return Value(); return Value();
} }
......
...@@ -251,7 +251,7 @@ Value RunConfig(const FunctionCallNode* function, ...@@ -251,7 +251,7 @@ Value RunConfig(const FunctionCallNode* function,
*err = Err(function, "Can't define a config in this context."); *err = Err(function, "Can't define a config in this context.");
return Value(); return Value();
} }
collector->push_back(new scoped_ptr<Item>(config.PassAs<Item>())); collector->push_back(config.release());
return Value(); return Value();
} }
......
...@@ -265,8 +265,10 @@ void LoaderImpl::BackgroundLoadFile(const Settings* settings, ...@@ -265,8 +265,10 @@ void LoaderImpl::BackgroundLoadFile(const Settings* settings,
g_scheduler->FailWithError(err); g_scheduler->FailWithError(err);
// Pass all of the items that were defined off to the builder. // Pass all of the items that were defined off to the builder.
for (const auto& item : collected_items) for (auto& item : collected_items) {
settings->build_settings()->ItemDefined(item->Pass()); settings->build_settings()->ItemDefined(make_scoped_ptr(item));
item = nullptr;
}
trace.Done(); trace.Done();
......
...@@ -40,9 +40,8 @@ class Template; ...@@ -40,9 +40,8 @@ class Template;
class Scope { class Scope {
public: public:
typedef base::hash_map<base::StringPiece, Value> KeyValueMap; typedef base::hash_map<base::StringPiece, Value> KeyValueMap;
// Holds an owning list of scoped_ptrs of Items (since we can't make a vector // Holds an owning list of Items.
// of scoped_ptrs). typedef ScopedVector<Item> ItemVector;
typedef ScopedVector< scoped_ptr<Item> > ItemVector;
// Allows code to provide values for built-in variables. This class will // Allows code to provide values for built-in variables. This class will
// automatically register itself on construction and deregister itself on // automatically register itself on construction and deregister itself on
......
...@@ -126,7 +126,7 @@ void TargetGenerator::GenerateTarget(Scope* scope, ...@@ -126,7 +126,7 @@ void TargetGenerator::GenerateTarget(Scope* scope,
*err = Err(function_call, "Can't define a target in this context."); *err = Err(function_call, "Can't define a target in this context.");
return; return;
} }
collector->push_back(new scoped_ptr<Item>(target.PassAs<Item>())); collector->push_back(target.release());
} }
const BuildSettings* TargetGenerator::GetBuildSettings() const { const BuildSettings* TargetGenerator::GetBuildSettings() const {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment