irods / irods_capability_storage_tiering

BSD 3-Clause "New" or "Revised" License
5 stars 10 forks source link

configuration value fetching is inefficient #178

Open SwooshyCueb opened 2 years ago

SwooshyCueb commented 2 years ago

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: https://github.com/irods/irods_capability_storage_tiering/blob/7ec95618c6a94c358ce1ffec1fb05bc3e9b1352d/storage_tiering_configuration.cpp#L23-L26

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