From 4bad85b59334467ac839ed2dd91abb6625bc5b89 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sun, 7 Feb 2021 14:52:04 +0100 Subject: 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); } --- wayland.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'wayland.c') diff --git a/wayland.c b/wayland.c index 2a79bb10..255adf1f 100644 --- a/wayland.c +++ b/wayland.c @@ -1240,13 +1240,15 @@ wayl_destroy(struct wayland *wayl) fdm_hook_del(wayl->fdm, &fdm_hook, FDM_HOOK_PRIORITY_LOW); - tll_foreach(wayl->monitors, it) + tll_foreach(wayl->monitors, it) { monitor_destroy(&it->item); - tll_free(wayl->monitors); + tll_remove(wayl->monitors, it); + } - tll_foreach(wayl->seats, it) + tll_foreach(wayl->seats, it) { seat_destroy(&it->item); - tll_free(wayl->seats); + tll_remove(wayl->seats, it); + } #if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED if (wayl->text_input_manager != NULL) @@ -1431,8 +1433,8 @@ wayl_win_destroy(struct wl_window *win) wl_subsurface_destroy(it->item.sub_surf); if (it->item.surf != NULL) wl_surface_destroy(it->item.surf); + tll_remove(win->urls, it); } - tll_free(win->urls); csd_destroy(win); if (win->render_timer_sub_surface != NULL) -- cgit v1.3