[PATCH 1/6] nextchar(): get rid of special[]
Al Viro <[email protected]> Tue, 31 Mar 2026 09:07:24 +0100
| Newsgroups | org.kernel.vger.linux-sparse |
|---|---|
| Message-ID | <[email protected]> |
We want to hit the slow path on '\t', '\n', '\\' and '\r'. Doing that as series of checks is painful, but we don't need to be that precise - we almost never see control symbols outside of that set and the slow path will handle them just fine. And checking if character belongs to [\0-\017\\] is easy enough without bothering with storing the set as an array. Signed-off-by: Al Viro <[email protected]> --- tokenize.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tokenize.c b/tokenize.c index 85bc3f49..c3c6c234 100644 --- a/tokenize.c +++ b/tokenize.c @@ -441,10 +441,7 @@ static inline int nextchar(stream_t *stream) if (offset < stream->size) { int c = stream->buffer[offset++]; - static const char special[256] = { - ['\t'] = 1, ['\r'] = 1, ['\n'] = 1, ['\\'] = 1 - }; - if (!special[c]) { + if (c >= ' ' && c != '\\') { stream->offset = offset; stream->pos++; return c; -- 2.47.3