Skip to content

Commit

Permalink
NetCDF Codec fix (wrong logic)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmaciel committed Nov 23, 2024
1 parent 83c8d1e commit 1808114
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions src/mir/netcdf/Codec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,22 +168,10 @@ Codec* CodecFactory::build(const std::string& name, const Variable& variable) {

Log::debug() << "CodecFactory: looking for '" << name << "'" << std::endl;

if (auto j = m->find(name); j == m->end()) {
if (auto j = m->find(name); j != m->end()) {
return j->second->make(variable);
}

auto trim = [](const std::string& str, const std::string& trimmable) -> std::string {
size_t first = str.find_first_not_of(trimmable);
size_t last = str.find_last_not_of(trimmable);

return first == std::string::npos || last == 0 ? "" : str.substr(first, last - first + 1);
};

if (auto name_trimmed = trim(name, " \t\n\r\f\v"); name_trimmed != name) {
Log::warning() << "CodecFactory: looking for (trimmed) '" << name << "'" << std::endl;
return build(name_trimmed, variable);
}

list(Log::error() << "CodecFactory: unknown '" << name << "', choices are: ");
throw exception::SeriousBug("CodecFactory: unknown '" + name + "'");
}
Expand Down

0 comments on commit 1808114

Please sign in to comment.