diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-04-29 00:23:27 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-04-29 00:26:32 +0200 |
commit | 9caccbfec112c53133aff09119eda623ae0644fe (patch) | |
tree | 04a834f78a64809d0474dc5e6c4e1287c7bb01af /bin/gensquashfs | |
parent | 301ca5d2f14e85c54133c068fcee3e4544d68ccf (diff) |
gensquashfs: simplify sort_file_list
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'bin/gensquashfs')
-rw-r--r-- | bin/gensquashfs/src/sort_by_file.c | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/bin/gensquashfs/src/sort_by_file.c b/bin/gensquashfs/src/sort_by_file.c index a1aacc0..023dfb5 100644 --- a/bin/gensquashfs/src/sort_by_file.c +++ b/bin/gensquashfs/src/sort_by_file.c @@ -211,40 +211,32 @@ static void sort_file_list(fstree_t *fs) tree_node_t *out = NULL, *out_last = NULL; while (fs->files != NULL) { - sqfs_s64 lowest = fs->files->data.file.priority; - tree_node_t *it, *prev; - - for (it = fs->files; it != NULL; it = it->next_by_type) { - if (it->data.file.priority < lowest) - lowest = it->data.file.priority; - } - - it = fs->files; - prev = NULL; + tree_node_t *low = fs->files, *low_prev = NULL; + tree_node_t *it = low->next_by_type, *prev = low; while (it != NULL) { - if (it->data.file.priority != lowest) { - prev = it; - it = it->next_by_type; - continue; - } - - if (prev == NULL) { - fs->files = it->next_by_type; - } else { - prev->next_by_type = it->next_by_type; + if (it->data.file.priority < low->data.file.priority) { + low = it; + low_prev = prev; } + prev = it; + it = it->next_by_type; + } - if (out == NULL) { - out = it; - } else { - out_last->next_by_type = it; - } + if (low_prev == NULL) { + fs->files = low->next_by_type; + } else { + low_prev->next_by_type = low->next_by_type; + } - out_last = it; - it = it->next_by_type; - out_last->next_by_type = NULL; + if (out == NULL) { + out = low; + } else { + out_last->next_by_type = low; } + + out_last = low; + low->next_by_type = NULL; } fs->files = out; |