summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasahiro Yamada <masahiroy@kernel.org>2020-08-22 23:56:09 +0900
committerMasahiro Yamada <masahiroy@kernel.org>2020-08-27 00:44:33 +0900
commit8a685db32f2b3495c91efab6e9462c2fd934778f (patch)
tree19cf8b56d9cca1837b7d4f42c9d6593f9f54e224
parent23cd88c91343349a0d67a227f9effdde0cbe09af (diff)
downloadlinux-stable-8a685db32f2b3495c91efab6e9462c2fd934778f.tar.gz
linux-stable-8a685db32f2b3495c91efab6e9462c2fd934778f.tar.bz2
linux-stable-8a685db32f2b3495c91efab6e9462c2fd934778f.zip
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: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Tested-by: Nick Desaulniers <ndesaulniers@google.com>
-rwxr-xr-xscripts/gen_compile_commands.py7
1 files changed, 2 insertions, 5 deletions
diff --git a/scripts/gen_compile_commands.py b/scripts/gen_compile_commands.py
index c458696ef3a7..1bcf33a93cb9 100755
--- a/scripts/gen_compile_commands.py
+++ b/scripts/gen_compile_commands.py
@@ -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))