Skip to content

Commit

Permalink
Simplify if statement with unordered_map
Browse files Browse the repository at this point in the history
  • Loading branch information
JCGoran committed Aug 14, 2024
1 parent 09d0490 commit 266eacd
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions src/nmodl/solve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,13 @@ void solvhandler() {
lq = lq->next;
method = SYM(lq);
cvodemethod_ = 0;
if (method && strcmp(method->name, "after_cvode") == 0) {
method = (Symbol*) 0;
lq->element.sym = (Symbol*) 0;
cvodemethod_ = 1;
}
if (method && strcmp(method->name, "cvode_t") == 0) {
method = (Symbol*) 0;
lq->element.sym = (Symbol*) 0;
cvodemethod_ = 2;
}
if (method && strcmp(method->name, "cvode_v") == 0) {
method = (Symbol*) 0;
lq->element.sym = (Symbol*) 0;
cvodemethod_ = 3;
const std::unordered_map<std::string, int> methods = {{"after_cvode", 1},

Check failure on line 129 in src/nmodl/solve.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-22.04 - cmake (-DNRN_ENABLE_CORENEURON=ON -DNRN_ENABLE_INTERVIEWS=OFF -DNMODL_SANITIZERS=undefinedundefined)

no template named 'unordered_map' in namespace 'std'
{"cvode_t", 2},
{"cvode_v", 3}};
if (method && methods.count(method->name)) {
cvodemethod_ = methods.at(method->name);
method = nullptr;
lq->element.sym = nullptr;
}
lq = lq->next;
errstmt = LST(lq);
Expand Down

0 comments on commit 266eacd

Please sign in to comment.