diff --git a/plugins/arclite/plugin.cpp b/plugins/arclite/plugin.cpp index 4f635d31ac..11e5fafb6a 100644 --- a/plugins/arclite/plugin.cpp +++ b/plugins/arclite/plugin.cpp @@ -702,8 +702,10 @@ class Plugin }); const auto error_log = std::make_shared(); size_t im = 0, nm = matched_indices.size(); + std::vector indices; + indices.reserve(nm); while (im < nm) { - std::vector indices; + indices.clear(); auto parent = archive->file_list[matched_indices[im]].parent; while (im < nm && archive->file_list[matched_indices[im]].parent == parent) indices.push_back(matched_indices[im++]); diff --git a/plugins/arclite/sfx.cpp b/plugins/arclite/sfx.cpp index 9a4c927be2..d4ae71870c 100644 --- a/plugins/arclite/sfx.cpp +++ b/plugins/arclite/sfx.cpp @@ -352,7 +352,7 @@ class SfxOptionsDialog: public Far::Dialog { bool show() { label(Far::get_msg(MSG_SFX_OPTIONS_DLG_PROFILE)); std::vector profile_names; - profile_names.reserve(profiles.size()); + profile_names.reserve(profiles.size() + 1); for (unsigned i = 0; i < profiles.size(); i++) { profile_names.push_back(profiles[i].name); } diff --git a/plugins/arclite/ui.cpp b/plugins/arclite/ui.cpp index 63ff30af16..f29e0b298d 100644 --- a/plugins/arclite/ui.cpp +++ b/plugins/arclite/ui.cpp @@ -1077,6 +1077,7 @@ class UpdateDialog: public Far::Dialog { void populate_profile_list() { DisableEvents de(*this); std::vector fl_items; + fl_items.reserve(profiles.size() + 1); FarListItem fl_item{}; for (unsigned i = 0; i < profiles.size(); i++) { fl_item.Text = profiles[i].name.c_str(); @@ -1280,7 +1281,7 @@ class UpdateDialog: public Far::Dialog { old_ext = ArcAPI::formats().at(m_options.arc_type).default_extension(); std::vector profile_names; - profile_names.reserve(profiles.size()); + profile_names.reserve(profiles.size() + 1); unsigned profile_idx = static_cast(profiles.size()); std::for_each(profiles.begin(), profiles.end(), [&] (const UpdateProfile& profile) { profile_names.push_back(profile.name); @@ -1345,6 +1346,7 @@ class UpdateDialog: public Far::Dialog { return _wcsicmp(a_format.name.c_str(), b_format.name.c_str()) < 0; }); std::vector other_format_names; + other_format_names.reserve(other_formats.size()); unsigned other_format_index = 0; bool found = false; for (const auto& t : other_formats) { @@ -1378,9 +1380,11 @@ class UpdateDialog: public Far::Dialog { label(Far::get_msg(MSG_UPDATE_DLG_METHOD)); std::wstring method = m_options.method.empty() && m_options.arc_type == c_7z? c_methods[0].value : m_options.method; std::vector method_names; + const auto sizeMethods = ARRAYSIZE(c_methods) + ArcAPI::Count7zCodecs(); + method_names.reserve(sizeMethods); const auto& codecs = ArcAPI::codecs(); unsigned method_sel = 0; - for (unsigned i = 0; i < ARRAYSIZE(c_methods) + ArcAPI::Count7zCodecs(); ++i) { + for (unsigned i = 0; i < sizeMethods; ++i) { std::wstring method_name = i < ARRAYSIZE(c_methods) ? c_methods[i].value : codecs[i - ARRAYSIZE(c_methods)].Name; if (method == method_name) method_sel = i;