aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/pre-process.c
diff options
authorLinus Torvalds <torvalds@linux-foundation.org>2011-04-19 13:06:45 -0700
committerChristopher Li <sparse@chrisli.org>2011-04-19 13:52:12 -0700
commit87f4a7fda3d17c85e966e2a150084d6a1cf25ab4 (patch)
treed88774ee1cfcaf66eb8b3ceedaddf448ce8a4a1b /pre-process.c
parent52df775e6235b81ddb44f885214f40ea562a61ea (diff)
downloadsparse-dev-87f4a7fda3d17c85e966e2a150084d6a1cf25ab4.tar.gz
Teach 'already_tokenized()' to use the stream name hash table
This replaces the "loop over all streams" with a simple hash lookup. It makes the cost of checking for already tokenized streams basically go away (it could be up to 5% of CPU time, almost entirely due to the "strcmp()" of the name). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Christopher Li <sparse@chrisli.org>
Diffstat (limited to 'pre-process.c')
-rw-r--r--pre-process.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/pre-process.c b/pre-process.c
index 603cc00c..6d12f173 100644
--- a/pre-process.c
+++ b/pre-process.c
@@ -655,10 +655,12 @@ static const char *token_name_sequence(struct token *token, int endop, struct to
static int already_tokenized(const char *path)
{
- int i;
- struct stream *s = input_streams;
+ int stream, next;
+
+ for (stream = *hash_stream(path); stream >= 0 ; stream = next) {
+ struct stream *s = input_streams + stream;
- for (i = input_stream_nr; --i >= 0; s++) {
+ next = s->next_stream;
if (s->constant != CONSTANT_FILE_YES)
continue;
if (strcmp(path, s->name))