mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-24 01:40:12 -05:00
config: don’t use tllist where it isn’t necessary
tllists are great when dealing with dynamically changing lists. They are also very easy to use when building lists/arrays where the final size is unknown. However, this ease of use comes at a price: code size. tll-macros expand to a lot of code. Since things in the config are static, once the config has been loaded, using tllists for configuration data structures doesn’t make much sense. This patch replaces nearly all tllists used by the configuration, with dynamically allocated arrays.
This commit is contained in:
parent
31e10c1613
commit
495c730487
5 changed files with 380 additions and 276 deletions
17
main.c
17
main.c
|
|
@ -441,17 +441,22 @@ main(int argc, char *const *argv)
|
|||
if (login_shell)
|
||||
conf.login_shell = true;
|
||||
if (tll_length(conf_fonts) > 0) {
|
||||
for (size_t i = 0; i < ALEN(conf.fonts); i++) {
|
||||
tll_foreach(conf.fonts[i], it)
|
||||
config_font_destroy(&it->item);
|
||||
tll_free(conf.fonts[i]);
|
||||
}
|
||||
for (size_t i = 0; i < ALEN(conf.fonts); i++)
|
||||
config_font_list_destroy(&conf.fonts[i]);
|
||||
|
||||
struct config_font_list *font_list = &conf.fonts[0];
|
||||
xassert(font_list->count == 0);
|
||||
xassert(font_list->arr == NULL);
|
||||
|
||||
font_list->arr = xmalloc(
|
||||
tll_length(conf_fonts) * sizeof(font_list->arr[0]));
|
||||
|
||||
tll_foreach(conf_fonts, it) {
|
||||
struct config_font font;
|
||||
if (!config_font_parse(it->item, &font)) {
|
||||
LOG_ERR("%s: invalid font specification", it->item);
|
||||
} else
|
||||
tll_push_back(conf.fonts[0], font);
|
||||
font_list->arr[font_list->count++] = font;
|
||||
}
|
||||
tll_free(conf_fonts);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue