Skip to content

Commit 440f67c

Browse files
committed
kconfig: refactor expr_eliminate_dups()
Currently, expr_eliminate_dups() passes two identical pointers down to expr_eliminate_dups1(), which later skips processing identical leaves. This approach is somewhat tricky and, more importantly, it will not work with the refactoring made in the next commit. This commit slightly changes the recursion logic; it deduplicates both the left and right arms, and then passes them to expr_eliminate_dups1(). expr_eliminate_dups() should produce the same result. Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 4fa146e commit 440f67c

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

scripts/kconfig/expr.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -578,16 +578,6 @@ static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct
578578

579579
/* *ep1 and *ep2 are leaves. Compare and process them. */
580580

581-
if (*ep1 == *ep2)
582-
return;
583-
584-
switch ((*ep1)->type) {
585-
case E_OR: case E_AND:
586-
expr_eliminate_dups1((*ep1)->type, ep1, ep1);
587-
default:
588-
;
589-
}
590-
591581
switch (type) {
592582
case E_OR:
593583
tmp = expr_join_or(*ep1, *ep2);
@@ -634,7 +624,9 @@ struct expr *expr_eliminate_dups(struct expr *e)
634624
trans_count = 0;
635625
switch (e->type) {
636626
case E_OR: case E_AND:
637-
expr_eliminate_dups1(e->type, &e, &e);
627+
e->left.expr = expr_eliminate_dups(e->left.expr);
628+
e->right.expr = expr_eliminate_dups(e->right.expr);
629+
expr_eliminate_dups1(e->type, &e->left.expr, &e->right.expr);
638630
default:
639631
;
640632
}

0 commit comments

Comments
 (0)