mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-12 18:45:44 -07:00
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.
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user