Skip to content
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

Merged
merged 2 commits into from
Feb 7, 2023

Conversation

pkratoch
Copy link
Contributor

No description provided.

@pkratoch pkratoch force-pushed the module-query branch 2 times, most recently from 66d61ba to 711b8cb Compare January 31, 2023 14:38
@j-mracek j-mracek self-assigned this Feb 2, 2023
@@ -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 != "") {
Copy link
Contributor

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()) {

Copy link
Contributor Author

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,
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added and moved.

Copy link
Contributor

@j-mracek j-mracek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@j-mracek j-mracek merged commit 7f8a008 into rpm-software-management:main Feb 7, 2023
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]);
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants