url-mode: use shm_get_many()

If we have lots of URLs, we use up a *lot* of SHM buffers (and thus
pools). Each and every one is a single mmap(), of at least 4K.

Since all URL labels are created and destroyed at the same time, it
makes sense to use a single pool for all buffers.

To do this, we must now do two passes; first one to generate the
actual string (label content), and to calculate the label sizes.

Then we use this information to allocate all SHM buffers at once, from
the same pool.

Finally, we iterate the URLs again, this time to actually render them.
This commit is contained in:
Daniel Eklöf 2021-07-15 18:39:41 +02:00
parent 7533684d8f
commit 31fad58465
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
3 changed files with 79 additions and 17 deletions

View file

@ -14,7 +14,6 @@
#include "grid.h"
#include "render.h"
#include "selection.h"
#include "shm.h"
#include "spawn.h"
#include "terminal.h"
#include "uri.h"
@ -738,9 +737,7 @@ urls_reset(struct terminal *term)
if (term->window != NULL) {
tll_foreach(term->window->urls, it) {
const struct url *url = it->item.url;
wayl_win_subsurface_destroy(&it->item.surf);
shm_purge(term->wl->shm, shm_cookie_url(url));
tll_remove(term->window->urls, it);
}
}