From 4da9b7cc5b50c346309378fbb5ae8aa07746fd33 Mon Sep 17 00:00:00 2001 From: Tom Englund Date: Sun, 19 Jan 2025 10:38:42 +0000 Subject: core: reserve vector sizes as much as we can (#9118) avoid reallocations as much as possible with a few edge cases where the reservation overshoots a tiny bit. but a few bytes of memory short term is better used then the overhead of potential reallocation. --- src/Compositor.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/Compositor.cpp') diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 496ca4fe..889ae181 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -2785,11 +2785,9 @@ PHLWINDOW CCompositor::getForceFocus() { void CCompositor::arrangeMonitors() { static auto* const PXWLFORCESCALEZERO = (Hyprlang::INT* const*)g_pConfigManager->getConfigValuePtr("xwayland:force_zero_scaling"); - std::vector toArrange; + std::vector toArrange(m_vMonitors.begin(), m_vMonitors.end()); std::vector arranged; - - for (auto const& m : m_vMonitors) - toArrange.push_back(m); + arranged.reserve(toArrange.size()); Debug::log(LOG, "arrangeMonitors: {} to arrange", toArrange.size()); -- cgit v1.2.3