Skip to content

Fix and rename Config::find to Config::filter#452

Merged
nxpfrankli merged 1 commit intonxp-imx:masterfrom
markuspg:fix_find
Apr 25, 2025
Merged

Fix and rename Config::find to Config::filter#452
nxpfrankli merged 1 commit intonxp-imx:masterfrom
markuspg:fix_find

Conversation

@markuspg
Copy link
Copy Markdown
Contributor

I always scratched my head looking at Config Config::find(const string &pro), wondering about its purpose. If I don't misinterpret it it creates a new instance of Config - holding all default ConfigItems and then adds the ones of the current instance additionally which fit the passed protocol.

Since I guess it should rather filter I modified the Config constructor to allow creating an instance without any ConfigItems and then adding just selected ones within the filter function.

Comment thread libuuu/config.cpp Outdated
Config Config::filter(const string &pro)
{
Config items;
Config items{true};
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not really satisfied with the default argument approach. An alternative would be to leave the constructor unchanged and just call a clear on items before entering into the below for loop to start off from scratch.

Comment thread libuuu/config.cpp Outdated
emplace_back(ConfigItem{"FB:", nullptr, nullptr, NXP_VID, 0x0152});
emplace_back(ConfigItem{"FB:", nullptr, nullptr, 0x0483, 0x0afb});
if (!construct_empty) {
emplace_back(ConfigItem{"SDPS:", "MX8QXP", nullptr, NXP_VID, 0x012F, 0x0002});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry, missed this pull request. Suggest

if (construct_empty)
return;

....

to avoid move whole emplace_back.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No problem, there's always so much todo.

You suggestion is better. I changed the code accordingly.

Comment thread libuuu/config.cpp
Config Config::find(const string &pro)
Config Config::filter(const string &pro)
{
Config items;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for your patch. Look like Config::find(const string &pro) is never used. we can remove it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Dropped ✔️

Copy link
Copy Markdown
Contributor

@nxpfrankli nxpfrankli left a comment

Choose a reason for hiding this comment

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

Thank you for your patch. Look like Config::find(const string &pro) is never used. we can remove it.

Signed-off-by: markuspg <markuspg@users.noreply.github.com>
@nxpfrankli nxpfrankli merged commit f2a4e3e into nxp-imx:master Apr 25, 2025
16 of 18 checks passed
@markuspg markuspg deleted the fix_find branch April 25, 2025 08:27
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.

2 participants