Skip to content

Commit 09b2bfc

Browse files
committed
perf: add missing std::moves to save refcounting
1 parent 4077bf2 commit 09b2bfc

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

src/kernel/equiv_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ auto equiv_manager::mk_node() -> node_ref {
1414
node n;
1515
n.m_parent = r;
1616
n.m_rank = 0;
17-
m_nodes.push_back(n);
17+
m_nodes.push_back(std::move(n));
1818
return r;
1919
}
2020

src/kernel/instantiate_mvars.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class instantiate_lmvars_fn {
7878
after we update `mctx`. This is necessary because `m_cache`
7979
may contain references to its subterms.
8080
*/
81-
m_saved.push_back(a);
81+
m_saved.push_back(std::move(a));
8282
assign_lmvar(m_mctx, mvar_id(l), a_new);
8383
}
8484
return a_new;
@@ -169,7 +169,7 @@ class instantiate_mvars_fn {
169169
} else {
170170
expr a(r.get_val());
171171
if (!has_mvar(a) || m_already_normalized.contains(mid)) {
172-
return optional<expr>(a);
172+
return optional<expr>(std::move(a));
173173
} else {
174174
m_already_normalized.insert(mid);
175175
expr a_new = visit(a);
@@ -179,10 +179,10 @@ class instantiate_mvars_fn {
179179
after we update `mctx`. This is necessary because `m_cache`
180180
may contain references to its subterms.
181181
*/
182-
m_saved.push_back(a);
182+
m_saved.push_back(std::move(a));
183183
assign_mvar(m_mctx, mid, a_new);
184184
}
185-
return optional<expr>(a_new);
185+
return optional<expr>(std::move(a_new));
186186
}
187187
}
188188
}

src/kernel/type_checker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ expr type_checker::infer_lambda(expr const & _e, bool infer_only) {
120120
while (is_lambda(e)) {
121121
expr d = instantiate_rev(binding_domain(e), fvars.size(), fvars.data());
122122
expr fvar = m_lctx.mk_local_decl(m_st->m_ngen, binding_name(e), d, binding_info(e));
123-
fvars.push_back(fvar);
123+
fvars.push_back(std::move(fvar));
124124
if (!infer_only) {
125125
ensure_sort_core(infer_type_core(d, infer_only), d);
126126
}

src/library/constructions/cases_on.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ declaration mk_cases_on(environment const & env, name const & n) {
6464
while (is_pi(rec_type)) {
6565
expr local = lctx.mk_local_decl(ngen, binding_name(rec_type), binding_domain(rec_type), binding_info(rec_type));
6666
rec_type = instantiate(binding_body(rec_type), local);
67-
rec_fvars.push_back(local);
67+
rec_fvars.push_back(std::move(local));
6868
}
6969
/* Remark `rec_fvars` free variables represent the recursor:
7070
- Type parameters `As` (size == `num_params`)
@@ -137,7 +137,7 @@ declaration mk_cases_on(environment const & env, name const & n) {
137137
} else {
138138
expr new_local = lctx.mk_local_decl(ngen, binding_name(minor_type), mk_pi_unit(curr_type, unit),
139139
binding_info(minor_type));
140-
minor_params.push_back(new_local);
140+
minor_params.push_back(std::move(new_local));
141141
}
142142
} else {
143143
minor_params.push_back(local);

src/library/print.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ struct print_expr_fn {
207207
if (!is_nil(ls)) {
208208
out() << ".{";
209209
bool first = true;
210-
for (auto l : ls) {
210+
for (auto const & l : ls) {
211211
if (first) first = false; else out() << ", ";
212212
out() << l;
213213
}

0 commit comments

Comments
 (0)