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

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
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -125,11 +125,8 @@ def main():
            filepath = os.path.join(dirpath, filename)

            with open(filepath, 'rt') as f:
                for line in f:
                    result = line_matcher.match(line)
                    if not result:
                        continue

                result = line_matcher.match(f.readline())
                if result:
                    try:
                        entry = process_line(directory, dirpath,
                                             result.group(1), result.group(2))