macro processor: use `map.count()` instead of `map.find()`

issue#70
Houtan Bastani 2020-01-21 15:11:45 +01:00
parent 3c546ddb20
commit fa2f6c9206
No known key found for this signature in database
GPG Key ID: 000094FB955BE169
1 changed files with 2 additions and 2 deletions

View File

@ -26,7 +26,7 @@ void
Environment::define(VariablePtr var, ExpressionPtr value)
{
string name = var->getName();
if (functions.find(name) != functions.end())
if (functions.count(name))
throw StackTrace("Variable " + name + " was previously defined as a function");
variables[move(name)] = value->eval();
}
@ -35,7 +35,7 @@ void
Environment::define(FunctionPtr func, ExpressionPtr value)
{
string name = func->getName();
if (variables.find(name) != variables.end())
if (variables.count(name))
throw StackTrace("Variable " + name + " was previously defined as a variable");
functions[name] = {move(func), move(value)};
}