Skip to content

Commit

Permalink
sprinkle in some std::vector::reserve calls
Browse files Browse the repository at this point in the history
Reviewed By: thezhangwei

Differential Revision: D50584787

fbshipit-source-id: cd319cb3522f3e7125814302288b9bda171720d3
  • Loading branch information
Nikolai Tillmann authored and facebook-github-bot committed Oct 25, 2023
1 parent d837520 commit f8cbf68
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions opt/object-sensitive-dce/SideEffectSummary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ s_expr to_s_expr(const Summary& summary) {
std::vector<s_expr> s_exprs;
s_exprs.emplace_back(std::to_string(summary.effects));
std::vector<s_expr> mod_param_s_exprs;
mod_param_s_exprs.reserve(summary.modified_params.size());
for (auto idx : summary.modified_params) {
mod_param_s_exprs.emplace_back(idx);
}
Expand Down
1 change: 1 addition & 0 deletions opt/outliner/InstructionSequenceOutliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1738,6 +1738,7 @@ class OutlinedMethodCreator {
auto manager = g_redex->get_position_pattern_switch_manager();
// Order methods to make sure we get deterministic pattern-ids.
std::vector<DexMethod*> ordered_methods;
ordered_methods.reserve(ci.methods.size());
for (auto& p : ci.methods) {
ordered_methods.push_back(p.first);
}
Expand Down
2 changes: 2 additions & 0 deletions opt/virtual_merging/VirtualMerging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1375,6 +1375,8 @@ void VirtualMerging::merge_methods(
// Part 5: Remove methods within classes.
void VirtualMerging::remove_methods() {
std::vector<DexClass*> classes_with_virtual_methods_to_remove;
classes_with_virtual_methods_to_remove.reserve(
m_virtual_methods_to_remove.size());
for (auto& p : m_virtual_methods_to_remove) {
classes_with_virtual_methods_to_remove.push_back(p.first);
}
Expand Down

0 comments on commit f8cbf68

Please sign in to comment.