From 46d160e91acd8f2bf2efa52de18ddbbdb97a7b22 Mon Sep 17 00:00:00 2001 From: bad code <> Date: Sun, 22 Sep 2024 16:43:36 +0200 Subject: [PATCH] Reserve known vector size Allocate the required memory at once. --- src/btop_config.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/btop_config.cpp b/src/btop_config.cpp index 1647b21..55ef2ca 100644 --- a/src/btop_config.cpp +++ b/src/btop_config.cpp @@ -694,7 +694,8 @@ namespace Config { std::ifstream cread(conf_file); if (cread.good()) { vector valid_names; - for (auto &n : descriptions) + valid_names.reserve(descriptions.size()); + for (const auto &n : descriptions) valid_names.push_back(n[0]); if (string v_string; cread.peek() != '#' or (getline(cread, v_string, '\n') and not s_contains(v_string, Global::Version))) write_new = true;