-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
modules: Add NSVCAP parsing and ModuleQuery::filter_nsvca #260
Conversation
8e85ede
to
ec4b0c7
Compare
66d61ba
to
711b8cb
Compare
libdnf/module/module_query.cpp
Outdated
@@ -159,4 +160,28 @@ void ModuleQuery::filter_latest(int limit) { | |||
} | |||
|
|||
|
|||
void ModuleQuery::filter_nsvca(const Nsvcap & nsvcap, libdnf::sack::QueryCmp cmp) { | |||
const std::string & name = nsvcap.get_name(); | |||
if (name != "") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am sorry, I overlooked it. std::string has method empty that could be used instead. The difference is that the code compare the string form instead of asking whether length inside is 0. If I am correct, std::string knows its length therefore it should be cheaper.
if (!name.empty()) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, fixed.
Nsvcap::Form::NSP, | ||
Nsvcap::Form::NSV, | ||
Nsvcap::Form::NSVP, | ||
Nsvcap::Form::NSC, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May I ask you to add additional form - NSCP
?
Minor - May I also ask you to move NSC and NSCP before NSV
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added and moved.
711b8cb
to
5a819fc
Compare
5a819fc
to
5046107
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
bool Nsvcap::parse(const std::string nsvcap_str, Nsvcap::Form form) { | ||
enum { NAME = 1, STREAM = 2, VERSION = 3, CONTEXT = 4, ARCH = 5, PROFILE = 6, _LAST_ }; | ||
std::smatch matched_result; | ||
auto matched = std::regex_match(nsvcap_str, matched_result, NSVCAP_FORM_REGEX[static_cast<unsigned>(form) - 1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I worry this std::regex_match() call will suffer from the same issue as I fixed for RPM in #268.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, but creating an issue is sufficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can resolve it the same way: #299
No description provided.