mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-08-20 03:06:25 -06:00
always use overlaps instead of lookup for intervals
This commit is contained in:
@@ -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)
|
static size_t size(Node *node)
|
||||||
{
|
{
|
||||||
if (node == 0)
|
if (node == 0)
|
||||||
|
|||||||
@@ -1443,16 +1443,14 @@ void PgfParser::suspend(Cont *cont,Item *item,bool do_predict,size_t n_suspended
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
interval_t lin_idx_i = item->interval(ref<PgfLParam>::from_ptr(&symcat->r));
|
||||||
State *next = cont->state;
|
State *next = cont->state;
|
||||||
while (next != NULL) {
|
while (next != NULL) {
|
||||||
auto it1 = next->completed.find(cont);
|
auto it1 = next->completed.find(cont);
|
||||||
if (it1 != next->completed.end()) {
|
if (it1 != next->completed.end()) {
|
||||||
auto *it2 = it1->second.lookup(cont->ccat->value);
|
for (auto it2 : it1->second.overlaps(cont->ccat->value)) {
|
||||||
if (it2 != NULL) {
|
for (auto it3 : it2.second.overlaps(lin_idx_i)) {
|
||||||
interval_t lin_idx_i = item->interval(ref<PgfLParam>::from_ptr(&symcat->r));
|
CCat *arg = it3.second;
|
||||||
auto *it3 = it2->lookup(lin_idx_i);
|
|
||||||
if (it3 != NULL) {
|
|
||||||
CCat *arg = *it3;
|
|
||||||
Item *new_item = new (item) Item;
|
Item *new_item = new (item) Item;
|
||||||
combine(next, new_item, arg);
|
combine(next, new_item, arg);
|
||||||
}
|
}
|
||||||
@@ -1641,16 +1639,14 @@ void PgfParseTableMaker::suspend(Cont *cont,Item *item,bool do_predict,size_t n_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
interval_t lin_idx_i = item->interval(ref<PgfLParam>::from_ptr(&symcat->r));
|
||||||
State *next = cont->state;
|
State *next = cont->state;
|
||||||
while (next != NULL) {
|
while (next != NULL) {
|
||||||
auto it1 = next->completed.find(cont);
|
auto it1 = next->completed.find(cont);
|
||||||
if (it1 != next->completed.end()) {
|
if (it1 != next->completed.end()) {
|
||||||
auto *it2 = it1->second.lookup(cont->ccat->value);
|
for (auto it2 : it1->second.overlaps(cont->ccat->value)) {
|
||||||
if (it2 != NULL) {
|
for (auto it3 : it2.second.overlaps(lin_idx_i)) {
|
||||||
interval_t lin_idx_i = item->interval(ref<PgfLParam>::from_ptr(&symcat->r));
|
CCat *arg = it3.second;
|
||||||
auto *it3 = it2->lookup(lin_idx_i);
|
|
||||||
if (it3 != NULL) {
|
|
||||||
CCat *arg = *it3;
|
|
||||||
Item *new_item = new (item) Item;
|
Item *new_item = new (item) Item;
|
||||||
combine(next, new_item, arg);
|
combine(next, new_item, arg);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user