# HG changeset patch # User Thomas De Schampheleire # Date 1546166728 -3600 # Node ID a188803df37e148da6fa2168c013ef9b5b74e633 # Parent e7d6373631c4f41fc6eed16a670b576d94777ea5 scripts: docs-headings: improve performance by grouping 'hg diff' invocations With SSD, this change reduces the execution time of this script from 8 to 0.5 seconds diff -r e7d6373631c4 -r a188803df37e scripts/docs-headings.py --- a/scripts/docs-headings.py Fri Dec 28 21:56:52 2018 +0100 +++ b/scripts/docs-headings.py Sun Dec 30 11:45:28 2018 +0100 @@ -30,8 +30,9 @@ def main(): - for fn in subprocess.check_output(['hg', 'loc', 'set:**.rst+kallithea/i18n/how_to']).splitlines(): - print 'processing %s:' % fn + filenames = subprocess.check_output(['hg', 'loc', 'set:**.rst+kallithea/i18n/how_to']).splitlines() + for fn in filenames: + print 'processing %s' % fn s = open(fn).read() # find levels and their styles @@ -72,8 +73,8 @@ s = re.sub(r'''\n+((?:\.\. _[^\n]*\n)+)$''', r'\n\n\n\1', s) open(fn, 'w').write(s) - print subprocess.check_output(['hg', 'diff', fn]) - print + + print subprocess.check_output(['hg', 'diff'] + filenames) if __name__ == '__main__': main()