diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2021-02-07 13:52:04 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2021-02-08 09:09:59 +0000 |
| commit | 4bad85b59334467ac839ed2dd91abb6625bc5b89 (patch) | |
| tree | 58bc014c759d125b9c143283c5502219013e5f77 /terminal.c | |
| parent | Merge branch 'url-detection' (diff) | |
misc: when free:ing tll lists, prefer tll_remove() over tll_free()
In many places we have the following pattern:
tll_foreach(list, it)
free(it->item.thing);
tll_free(list);
Since all tll functions are macros, and thus inlined, and since
tll_free in itself expands to a tll_foreach(), the above pattern
expands to more native code than necessary.
This is somewhat smaller:
tll_foreach(list, it) {
free(it->item.thing);
tll_remove(list, it);
}
Diffstat (limited to 'terminal.c')
| -rw-r--r-- | terminal.c | 33 |
1 files changed, 20 insertions, 13 deletions
@@ -1474,20 +1474,25 @@ term_destroy(struct terminal *term) xassert(tll_length(term->render.workers.queue) == 0); tll_free(term->render.workers.queue); - tll_foreach(term->ptmx_buffers, it) + tll_free(term->tab_stops); + + tll_foreach(term->ptmx_buffers, it) { free(it->item.data); - tll_free(term->ptmx_buffers); - tll_foreach(term->ptmx_paste_buffers, it) + tll_remove(term->ptmx_buffers, it); + } + tll_foreach(term->ptmx_paste_buffers, it) { free(it->item.data); - tll_free(term->ptmx_paste_buffers); - tll_free(term->tab_stops); + tll_remove(term->ptmx_paste_buffers, it); + } - tll_foreach(term->normal.sixel_images, it) + tll_foreach(term->normal.sixel_images, it) { sixel_destroy(&it->item); - tll_free(term->normal.sixel_images); - tll_foreach(term->alt.sixel_images, it) + tll_remove(term->normal.sixel_images, it); + } + tll_foreach(term->alt.sixel_images, it) { sixel_destroy(&it->item); - tll_free(term->alt.sixel_images); + tll_remove(term->alt.sixel_images, it); + } sixel_fini(term); urls_reset(term); @@ -1642,12 +1647,14 @@ term_reset(struct terminal *term, bool hard) term->meta.esc_prefix = true; term->meta.eight_bit = true; - tll_foreach(term->normal.sixel_images, it) + tll_foreach(term->normal.sixel_images, it) { sixel_destroy(&it->item); - tll_free(term->normal.sixel_images); - tll_foreach(term->alt.sixel_images, it) + tll_remove(term->normal.sixel_images, it); + } + tll_foreach(term->alt.sixel_images, it) { sixel_destroy(&it->item); - tll_free(term->alt.sixel_images); + tll_remove(term->alt.sixel_images, it); + } #if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED term_ime_enable(term); |
