Traverse the filesystem only once when looking for UDI and Subiquity snaps. #258
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Here is the key of this PR:
For that to be possible,
hasAnyOfSnaps()
has to be implemented as a template function that can accept a variadic number ofstring_view
arguments and applies the existing algorithms to find entries inside the snap directory matching one of the supplied arguments. Since that receives a variadic argument in order to nicely composefind_file_if
andstd::any_of
we put together apush_back_many
algorithm that populates a vector of string_views from a variadic argument list.BTW,
find_file_if
returns a bool instead of iterator, so more likestd::any_of
thanstd::find_if
, thus the function was renamed toany_file_of
.And since there were some documentation comments lacking on the
algorithms.h
header and some unevitable linter complains about parameters of the same type instarts/ends_with
algorithms, I put some comments to stop linter at those lines.I think it is easier to review this PR commit by commit.