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:
parent
f56153a9c1
commit
4da9b7cc5b
11 changed files with 45 additions and 12 deletions
|
|
@ -75,6 +75,8 @@ void CX11DataDevice::sendEnter(uint32_t serial, SP<CWLSurfaceResource> surf, con
|
|||
data.data32[1] |= 1;
|
||||
|
||||
std::vector<xcb_atom_t> targets;
|
||||
// reserve to avoid reallocations
|
||||
targets.reserve(SOURCE->mimes().size());
|
||||
|
||||
for (auto& mime : SOURCE->mimes()) {
|
||||
targets.emplace_back(g_pXWayland->pWM->mimeToAtom(mime));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue