From dd2bf34cd0a39ad7869177f4379de55ad3603e53 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 6 Feb 2019 17:53:43 +0100 Subject: [PATCH] bootspec: only sort entries list once Instead of re-sorting entries list each time we loaded enrties from a specific source, let's just sort them once at the end. --- src/shared/bootspec.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/shared/bootspec.c b/src/shared/bootspec.c index ee285b92e65..2db6425f2f5 100644 --- a/src/shared/bootspec.c +++ b/src/shared/bootspec.c @@ -238,7 +238,6 @@ static int boot_entries_find( _cleanup_strv_free_ char **files = NULL; size_t n_allocated = *n_entries; - bool added = false; char **f; int r; @@ -260,12 +259,8 @@ static int boot_entries_find( continue; (*n_entries) ++; - added = true; } - if (added) - typesafe_qsort(*entries, *n_entries, boot_entry_compare); - return 0; } @@ -444,7 +439,6 @@ static int boot_entries_find_unified( _cleanup_(closedirp) DIR *d = NULL; size_t n_allocated = *n_entries; - bool added = false; struct dirent *de; int r; @@ -499,12 +493,8 @@ static int boot_entries_find_unified( continue; (*n_entries) ++; - added = true; } - if (added) - typesafe_qsort(*entries, *n_entries, boot_entry_compare); - return 0; } @@ -654,6 +644,8 @@ int boot_entries_load_config( return r; } + typesafe_qsort(config->entries, config->n_entries, boot_entry_compare); + r = boot_entries_uniquify(config->entries, config->n_entries); if (r < 0) return log_error_errno(r, "Failed to uniquify boot entries: %m"); -- 2.47.3