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

configuration value fetching is inefficient #178

Open
SwooshyCueb opened this issue Dec 10, 2021 · 0 comments
Open

configuration value fetching is inefficient #178

SwooshyCueb opened this issue Dec 10, 2021 · 0 comments
Assignees
Labels

Comments

@SwooshyCueb
Copy link
Member

At present, in storage_tiering_configuration.cpp, for each configuration value, we first check for the existence of the value with nlohmann::basic_json::find, before fetching the value with nlohmann::basic_json::at, like so:

if(plugin_spec_cfg.find("access_time_attribute") != plugin_spec_cfg.end()) {
access_time_attribute = boost::any_cast<std::string>(
plugin_spec_cfg.at("access_time_attribute"));
}

To my understanding, this is inefficient.
The return value of nlohmann::basic_json::find is an iterator, which will already contain the value we're looking for (or a reference to it) if it was found, but we throw it away and find the value again with nlohmann::basic_json::at.

See irods_server_properties.hpp for an example of proper usage of nlohmann::basic_json::find:
https://github.com/irods/irods/blob/84a09f945899b5ad85bb3d4cc451812e9dc05358/lib/core/include/irods_server_properties.hpp#L68-L71

@SwooshyCueb SwooshyCueb self-assigned this Dec 10, 2021
@trel trel added the bug label Dec 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants