[C++] Stop using shared_ptr in eval
diff --git a/dep.cc b/dep.cc
index 45f9584..920ba26 100644
--- a/dep.cc
+++ b/dep.cc
@@ -116,7 +116,7 @@
class DepBuilder {
public:
DepBuilder(Evaluator* ev,
- const vector<shared_ptr<Rule>>& rules,
+ const vector<const Rule*>& rules,
const unordered_map<Symbol, Vars*>& rule_vars)
: ev_(ev),
rule_vars_(rule_vars),
@@ -226,8 +226,8 @@
return ::Exists(target.str());
}
- void PopulateRules(const vector<shared_ptr<Rule>>& rules) {
- for (shared_ptr<Rule> rule : rules) {
+ void PopulateRules(const vector<const Rule*>& rules) {
+ for (const Rule* rule : rules) {
if (rule->outputs.empty()) {
PopulateImplicitRule(rule);
} else {
@@ -239,7 +239,7 @@
}
}
- bool PopulateSuffixRule(shared_ptr<Rule> rule, Symbol output) {
+ bool PopulateSuffixRule(const Rule* rule, Symbol output) {
if (output.empty() || output.str()[0] != '.')
return false;
@@ -337,7 +337,7 @@
return r;
}
- void PopulateExplicitRule(shared_ptr<Rule> orig_rule) {
+ void PopulateExplicitRule(const Rule* orig_rule) {
for (Symbol output : orig_rule->outputs) {
const bool is_suffix_rule = PopulateSuffixRule(orig_rule, output);
@@ -358,9 +358,9 @@
}
}
- void PopulateImplicitRule(shared_ptr<Rule> rule) {
+ void PopulateImplicitRule(const Rule* rule) {
for (Symbol output_pattern : rule->output_patterns) {
- implicit_rules_->Add(output_pattern.str(), rule.get());
+ implicit_rules_->Add(output_pattern.str(), rule);
}
}
@@ -619,7 +619,7 @@
};
void MakeDep(Evaluator* ev,
- const vector<shared_ptr<Rule>>& rules,
+ const vector<const Rule*>& rules,
const unordered_map<Symbol, Vars*>& rule_vars,
const vector<Symbol>& targets,
vector<DepNode*>* nodes) {
diff --git a/dep.h b/dep.h
index bb70eb3..05d10d0 100644
--- a/dep.h
+++ b/dep.h
@@ -15,7 +15,6 @@
#ifndef DEP_H_
#define DEP_H_
-#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
@@ -53,7 +52,7 @@
void QuitDepNodePool();
void MakeDep(Evaluator* ev,
- const vector<shared_ptr<Rule>>& rules,
+ const vector<const Rule*>& rules,
const unordered_map<Symbol, Vars*>& rule_vars,
const vector<Symbol>& targets,
vector<DepNode*>* nodes);
diff --git a/eval.cc b/eval.cc
index d4392b3..550f5eb 100644
--- a/eval.cc
+++ b/eval.cc
@@ -124,7 +124,7 @@
}
LOG("Rule: %s", rule->DebugString().c_str());
- rules_.push_back(shared_ptr<Rule>(rule));
+ rules_.push_back(rule);
last_rule_ = rule;
return;
}
diff --git a/eval.h b/eval.h
index c25edff..cb03d5d 100644
--- a/eval.h
+++ b/eval.h
@@ -15,7 +15,6 @@
#ifndef EVAL_H_
#define EVAL_H_
-#include <memory>
#include <unordered_map>
#include <unordered_set>
#include <vector>
@@ -53,7 +52,7 @@
const Loc& loc() const { return loc_; }
void set_loc(const Loc& loc) { loc_ = loc; }
- const vector<shared_ptr<Rule>>& rules() const { return rules_; }
+ const vector<const Rule*>& rules() const { return rules_; }
const unordered_map<Symbol, Vars*>& rule_vars() const {
return rule_vars_;
}
@@ -100,7 +99,7 @@
Vars* vars_;
unordered_map<Symbol, Vars*> rule_vars_;
- vector<shared_ptr<Rule>> rules_;
+ vector<const Rule*> rules_;
unordered_map<Symbol, bool> exports_;
Rule* last_rule_;