diff --git a/src/runtime/c/pgf/intervalmap.h b/src/runtime/c/pgf/intervalmap.h index ce8c4cf04..59020fb76 100644 --- a/src/runtime/c/pgf/intervalmap.h +++ b/src/runtime/c/pgf/intervalmap.h @@ -66,34 +66,6 @@ class PGF_INTERNAL_DECL interval_map { } } - static - V *lookup(Node *node, size_t start, size_t end) - { - if (node == NULL) { - return NULL; - } - - int cmp; - if (start < node->start) - cmp = -1; - else if (start > node->start) - cmp = 1; - else if (end < node->end) - cmp = -1; - else if (end > node->end) - cmp = 1; - else - cmp = 0; - - if (cmp < 0) { - return lookup(node->left, start, end); - } else if (cmp > 0) { - return lookup(node->right, start, end); - } else { - return &node->value; - } - } - static size_t size(Node *node) { if (node == 0) diff --git a/src/runtime/c/pgf/parser.cxx b/src/runtime/c/pgf/parser.cxx index 6c2de6cf1..70244f20d 100644 --- a/src/runtime/c/pgf/parser.cxx +++ b/src/runtime/c/pgf/parser.cxx @@ -1443,16 +1443,14 @@ void PgfParser::suspend(Cont *cont,Item *item,bool do_predict,size_t n_suspended } } } else { + interval_t lin_idx_i = item->interval(ref::from_ptr(&symcat->r)); State *next = cont->state; while (next != NULL) { auto it1 = next->completed.find(cont); if (it1 != next->completed.end()) { - auto *it2 = it1->second.lookup(cont->ccat->value); - if (it2 != NULL) { - interval_t lin_idx_i = item->interval(ref::from_ptr(&symcat->r)); - auto *it3 = it2->lookup(lin_idx_i); - if (it3 != NULL) { - CCat *arg = *it3; + for (auto it2 : it1->second.overlaps(cont->ccat->value)) { + for (auto it3 : it2.second.overlaps(lin_idx_i)) { + CCat *arg = it3.second; Item *new_item = new (item) Item; combine(next, new_item, arg); } @@ -1641,16 +1639,14 @@ void PgfParseTableMaker::suspend(Cont *cont,Item *item,bool do_predict,size_t n_ } } } else { + interval_t lin_idx_i = item->interval(ref::from_ptr(&symcat->r)); State *next = cont->state; while (next != NULL) { auto it1 = next->completed.find(cont); if (it1 != next->completed.end()) { - auto *it2 = it1->second.lookup(cont->ccat->value); - if (it2 != NULL) { - interval_t lin_idx_i = item->interval(ref::from_ptr(&symcat->r)); - auto *it3 = it2->lookup(lin_idx_i); - if (it3 != NULL) { - CCat *arg = *it3; + for (auto it2 : it1->second.overlaps(cont->ccat->value)) { + for (auto it3 : it2.second.overlaps(lin_idx_i)) { + CCat *arg = it3.second; Item *new_item = new (item) Item; combine(next, new_item, arg); }