From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Masahiro Yamada <masahiroy@kernel.org>
Subject: [PATCH 4/6] kconfig: refactor expr_eliminate_dups()
Date: Sun, 8 Sep 2024 21:43:19 +0900 [thread overview]
Message-ID: <20240908124352.1828890-4-masahiroy@kernel.org> (raw)
In-Reply-To: <20240908124352.1828890-1-masahiroy@kernel.org>
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 <masahiroy@kernel.org>
---
scripts/kconfig/expr.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c
index e83fe0c3d62f..5b826d197f12 100644
--- a/scripts/kconfig/expr.c
+++ b/scripts/kconfig/expr.c
@@ -578,16 +578,6 @@ static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct
/* *ep1 and *ep2 are leaves. Compare and process them. */
- if (*ep1 == *ep2)
- return;
-
- switch ((*ep1)->type) {
- case E_OR: case E_AND:
- expr_eliminate_dups1((*ep1)->type, ep1, ep1);
- default:
- ;
- }
-
switch (type) {
case E_OR:
tmp = expr_join_or(*ep1, *ep2);
@@ -634,7 +624,9 @@ struct expr *expr_eliminate_dups(struct expr *e)
trans_count = 0;
switch (e->type) {
case E_OR: case E_AND:
- expr_eliminate_dups1(e->type, &e, &e);
+ e->left.expr = expr_eliminate_dups(e->left.expr);
+ e->right.expr = expr_eliminate_dups(e->right.expr);
+ expr_eliminate_dups1(e->type, &e->left.expr, &e->right.expr);
default:
;
}
--
2.43.0
next prev parent reply other threads:[~2024-09-08 12:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-08 12:43 [PATCH 1/6] scripts: move hash function from scripts/kconfig/ to scripts/include/ Masahiro Yamada
2024-09-08 12:43 ` [PATCH 2/6] kconfig: change some expr_*() functions to bool Masahiro Yamada
2024-09-08 12:43 ` [PATCH 3/6] kconfig: add comments to expression transformations Masahiro Yamada
2024-09-08 12:43 ` Masahiro Yamada [this message]
2024-09-08 12:43 ` [PATCH 5/6] kconfig: use hash table to reuse expressions Masahiro Yamada
2024-09-08 12:43 ` [PATCH 6/6] kconfig: cache expression values Masahiro Yamada
2024-09-30 13:30 ` Masahiro Yamada
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240908124352.1828890-4-masahiroy@kernel.org \
--to=masahiroy@kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox