Commit 8a685db3 authored by Masahiro Yamada's avatar Masahiro Yamada

gen_compile_commands: parse only the first line of .*.cmd files

After the allmodconfig build, this script takes about 5 sec on my
machine. Most of the run-time is consumed for needless regex matching.

We know the format of .*.cmd file; the first line is the build command.
There is no need to parse the rest.

With this optimization, now it runs 4 times faster.
Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
Tested-by: default avatarNick Desaulniers <ndesaulniers@google.com>
parent 23cd88c9
...@@ -125,11 +125,8 @@ def main(): ...@@ -125,11 +125,8 @@ def main():
filepath = os.path.join(dirpath, filename) filepath = os.path.join(dirpath, filename)
with open(filepath, 'rt') as f: with open(filepath, 'rt') as f:
for line in f: result = line_matcher.match(f.readline())
result = line_matcher.match(line) if result:
if not result:
continue
try: try:
entry = process_line(directory, dirpath, entry = process_line(directory, dirpath,
result.group(1), result.group(2)) result.group(1), result.group(2))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment