Remove extra operator when simplifying nested domains

issue11406
review390621002
This commit is contained in:
Nicolas Évrard
2022-04-14 10:21:53 +02:00
parent 7c92207507
commit 600f22f43a
2 changed files with 14 additions and 4 deletions
+11 -4
View File
@@ -2574,12 +2574,19 @@
return this.simplify_nested(domain[0]);
} else {
var simplified = [];
var domain_op = this._bool_operator(domain);
for (var branch of domain) {
var simplified_branch = this.simplify_nested(branch);
if ((this._bool_operator(branch) == domain_op) ||
(simplified_branch.length == 1)) {
simplified.push(...simplified_branch);
if ((this._bool_operator(simplified_branch) ==
this._bool_operator(simplified)) ||
(simplified_branch.length == 1)) {
if ((simplified.length > 0) &&
(simplified_branch.length > 0) &&
((simplified_branch[0] == 'AND') ||
(simplified_branch[0] == 'OR'))) {
simplified.push(...simplified_branch.slice(1));
} else {
simplified.push(...simplified_branch);
}
} else {
simplified.push(simplified_branch);
}
+3
View File
@@ -2612,6 +2612,9 @@
[
['OR', ['x', '=', 3], ['AND', ['y', '=', 5]]],
['OR', ['x', '=', 3], ['y', '=', 5]]],
[
['OR', ['x', '=', 1], ['OR', ['x', '=', 2], ['x', '=', 3]]],
['OR', ['x', '=', 1], ['x', '=', 2], ['x', '=', 3]]],
[[['x', '=', 3], ['OR']], [['x', '=', 3]]],
[['OR', ['x', '=', 3], []], []],
[['OR', ['x', '=', 3], ['OR']], []],