mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-21 05:33:45 -04:00
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:
parent
63a50afc8e
commit
4bad85b593
4 changed files with 36 additions and 25 deletions
10
config.c
10
config.c
|
|
@ -2379,9 +2379,10 @@ config_load(struct config *conf, const char *conf_path,
|
|||
conf->url_launch.raw_cmd = xstrdup("xdg-open ${url}");
|
||||
tokenize_cmdline(conf->url_launch.raw_cmd, &conf->url_launch.argv);
|
||||
|
||||
tll_foreach(*initial_user_notifications, it)
|
||||
tll_foreach(*initial_user_notifications, it) {
|
||||
tll_push_back(conf->notifications, it->item);
|
||||
tll_free(*initial_user_notifications);
|
||||
tll_remove(*initial_user_notifications, it);
|
||||
}
|
||||
|
||||
add_default_key_bindings(conf);
|
||||
add_default_search_bindings(conf);
|
||||
|
|
@ -2462,9 +2463,10 @@ config_free(struct config conf)
|
|||
free_spawn_template(&conf.notify);
|
||||
free_spawn_template(&conf.url_launch);
|
||||
for (size_t i = 0; i < ALEN(conf.fonts); i++) {
|
||||
tll_foreach(conf.fonts[i], it)
|
||||
tll_foreach(conf.fonts[i], it) {
|
||||
config_font_destroy(&it->item);
|
||||
tll_free(conf.fonts[i]);
|
||||
tll_remove(conf.fonts[i], it);
|
||||
}
|
||||
}
|
||||
free(conf.server_socket_path);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue