Skip to content

Commit

Permalink
use parse() instead of string_to_enum().
Browse files Browse the repository at this point in the history
this is faster if the string doesn't match because it doesn't throw an
exception in that case.
  • Loading branch information
gfgtdf committed Jan 20, 2016
1 parent 0f8998d commit ee05913
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/unit_filter.cpp
Expand Up @@ -122,16 +122,14 @@ class basic_unit_filter_impl : public unit_filter_abstract_impl {
while(cond != cond_end)
{
const std::string& cond_name = cond.get_key();

try {
conditional::TYPE type = conditional::TYPE::string_to_enum(cond_name); // throws bad_enum_cast if we don't get a string match with any enum

conditional::TYPE type;
if(type.parse(cond_name)) {
const vconfig& cond_filter = cond.get_child();

cond_children_.push_back(unit_filter(cond_filter, &fc_, use_flat_tod_));
cond_child_types_.push_back(type);
} catch (bad_enum_cast &) { // this means it isn't a conditional filter tag

cond_child_types_.push_back(type);
}
else {
static const int NUM_VALID_TAGS = 5;
static const std::string valid_tags[NUM_VALID_TAGS] = {
"filter_vision",
Expand All @@ -147,6 +145,7 @@ class basic_unit_filter_impl : public unit_filter_abstract_impl {
errmsg << "encountered a child [" << cond_name << "] of a standard unit filter, it is being ignored";
DBG_CF << errmsg.str() << std::endl; //FAIL( errmsg.str() );
}

}
++cond;
}
Expand Down

0 comments on commit ee05913

Please sign in to comment.