History

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.

Masahiro Yamada committed 6 years ago

Commit 8a685db1 parent 23cd88c1 file · +2 −5Browse files

Unified · Split

scripts/gen_compile_commands.py+2−5
@@ -125,11 +125,8 @@ def main(): · 124 unmodified lines
125125 filepath = os.path.join(dirpath, filename)
126126
127127 with open(filepath, 'rt') as f:
128− for line in f:
129− result = line_matcher.match(line)
130− if not result:
131− continue
132−
128+ result = line_matcher.match(f.readline())
129+ if result:
133130 try:
134131 entry = process_line(directory, dirpath,
135132 result.group(1), result.group(2))