Prune unneeded stack versions based on a depth criteria
This commit is contained in:
parent
d6579956f5
commit
eccb3893eb
4 changed files with 20 additions and 2 deletions
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
static const unsigned MAX_COST_DIFFERENCE = 16 * ERROR_COST_PER_SKIPPED_TREE;
|
||||
static const unsigned MAX_PUSH_COUNT_WITH_COUNT_DIFFERENCE = 24;
|
||||
static const unsigned MAX_PUSH_COUNT_TO_ALLOW_MULTIPLE = 32;
|
||||
static const unsigned MAX_DEPTH_TO_ALLOW_MULTIPLE = 12;
|
||||
|
||||
ErrorComparison error_status_compare(ErrorStatus a, ErrorStatus b, bool are_mergeable) {
|
||||
if (a.count < b.count) {
|
||||
|
|
@ -42,5 +44,20 @@ ErrorComparison error_status_compare(ErrorStatus a, ErrorStatus b, bool are_merg
|
|||
}
|
||||
}
|
||||
|
||||
if (a.count > 0) {
|
||||
if (a.push_count > MAX_PUSH_COUNT_TO_ALLOW_MULTIPLE ||
|
||||
b.push_count > MAX_PUSH_COUNT_TO_ALLOW_MULTIPLE ||
|
||||
a.depth > MAX_DEPTH_TO_ALLOW_MULTIPLE ||
|
||||
b.depth > MAX_DEPTH_TO_ALLOW_MULTIPLE) {
|
||||
return a.depth <= b.depth ?
|
||||
ErrorComparisonTakeLeft :
|
||||
ErrorComparisonTakeRight;
|
||||
} else {
|
||||
return a.depth <= b.depth ?
|
||||
ErrorComparisonPreferLeft :
|
||||
ErrorComparisonPreferRight;
|
||||
}
|
||||
}
|
||||
|
||||
return ErrorComparisonNone;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ typedef struct {
|
|||
unsigned count;
|
||||
unsigned cost;
|
||||
unsigned push_count;
|
||||
unsigned depth;
|
||||
} ErrorStatus;
|
||||
|
||||
typedef enum {
|
||||
|
|
|
|||
|
|
@ -384,6 +384,7 @@ ErrorStatus ts_stack_error_status(const Stack *self, StackVersion version) {
|
|||
.cost = head->node->error_cost,
|
||||
.count = head->node->error_count,
|
||||
.push_count = head->push_count,
|
||||
.depth = head->depth,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue