diff options
| author | Tom Englund <tomenglund26@gmail.com> | 2025-01-19 10:38:42 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-19 10:38:42 +0000 |
| commit | 4da9b7cc5b50c346309378fbb5ae8aa07746fd33 (patch) | |
| tree | a618fb83c13bac02729751d866a884e7207d08e7 /src/xwayland/XWM.cpp | |
| parent | f56153a9c1b0a00fac0932a95e0cfa5a4f6c681f (diff) | |
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.
Diffstat (limited to 'src/xwayland/XWM.cpp')
| -rw-r--r-- | src/xwayland/XWM.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/xwayland/XWM.cpp b/src/xwayland/XWM.cpp index 44485381..ae8e0ccc 100644 --- a/src/xwayland/XWM.cpp +++ b/src/xwayland/XWM.cpp @@ -643,6 +643,8 @@ void CXWM::handleSelectionRequest(xcb_selection_request_event_t* e) { Debug::log(WARN, "[xwm] WARNING: No mimes in TARGETS?"); std::vector<xcb_atom_t> atoms; + // reserve to avoid reallocations + atoms.reserve(mimes.size() + 2); atoms.push_back(HYPRATOMS["TIMESTAMP"]); atoms.push_back(HYPRATOMS["TARGETS"]); @@ -989,6 +991,8 @@ void CXWM::sendState(SP<CXWaylandSurface> surf) { } std::vector<uint32_t> props; + // reserve to avoid reallocations + props.reserve(6); // props below if (surf->modal) props.push_back(HYPRATOMS["_NET_WM_STATE_MODAL"]); if (surf->fullscreen) |
