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.
This commit is contained in:
+2
-10
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user