[PATCH 03/21] more dup_token() optimizations

Al Viro <[email protected]> Mon, 16 Mar 2026 07:03:57 +0000
Newsgroups org.kernel.vger.linux-sparse
Message-ID <[email protected]>
pull handling to tainted identifiers into dup_token(), eliminating reread
and resulting stall in there.

Signed-off-by: Al Viro <[email protected]>
---
 pre-process.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/pre-process.c b/pre-process.c
index e43061b2..320a5247 100644
--- a/pre-process.c
+++ b/pre-process.c
@@ -583,18 +583,21 @@ static int merge(struct token *left, struct token *right)
 	return 0;
 }
 
-static struct token *dup_token(const struct token *token, struct position *streampos)
+static inline struct token *dup_token(const struct token *token, struct position *streampos)
 {
 	struct position pos = *streampos;
 	struct token *alloc = __alloc_token(0);
+	struct position pos2 = token->pos;
 
-	alloc->pos = token->pos;
-	alloc->number = token->number;
-	alloc->pos.stream = pos.stream;
-	alloc->pos.line = pos.line;
-	alloc->pos.pos = pos.pos;
-	if (token_type(alloc) == TOKEN_STRING || token_type(alloc) == TOKEN_WIDE_STRING)
+	alloc->ident = token->ident;
+	pos2.stream = pos.stream;
+	pos2.line = pos.line;
+	pos2.pos = pos.pos;
+	if (pos2.type == TOKEN_STRING || pos2.type == TOKEN_WIDE_STRING)
 		token->string->immutable = 1;
+	if (pos2.type == TOKEN_IDENT && token->ident->tainted)
+		pos2.noexpand = 1;
+	alloc->pos = pos2;
 	return alloc;	
 }
 
@@ -728,9 +731,6 @@ static struct token **substitute(struct token **list, const struct token *body,
 
 		default:
 			added = dup_token(body, base_pos);
-			if (token_type(body) == TOKEN_IDENT &&
-			    added->ident->tainted)
-				added->pos.noexpand = 1;
 			tail = &added->next;
 			break;
 		}
-- 
2.47.3