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);
  }
This commit is contained in:
Daniel Eklöf 2021-02-07 14:52:04 +01:00
parent 63a50afc8e
commit 4bad85b593
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
4 changed files with 36 additions and 25 deletions

View file

@ -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)