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/xwayland/Dnd.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/xwayland/Dnd.cpp') diff --git a/src/xwayland/Dnd.cpp b/src/xwayland/Dnd.cpp index 58fc6db3..d4ae3780 100644 --- a/src/xwayland/Dnd.cpp +++ b/src/xwayland/Dnd.cpp @@ -75,6 +75,8 @@ void CX11DataDevice::sendEnter(uint32_t serial, SP surf, con data.data32[1] |= 1; std::vector targets; + // reserve to avoid reallocations + targets.reserve(SOURCE->mimes().size()); for (auto& mime : SOURCE->mimes()) { targets.emplace_back(g_pXWayland->pWM->mimeToAtom(mime)); -- cgit v1.2.3