mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-02 04:15:46 +00:00
scripts: speedup prohibit-duplicate-header
Running regular expressions with capture groups is expensive. Bail out early if the line does not start with a '#'. This reduces the runtime of the check by two thirds. Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
05d28facb5
commit
424a385c3a
@ -30,6 +30,10 @@ def check_file(filename):
|
|||||||
for line in fh:
|
for line in fh:
|
||||||
lineno = lineno + 1
|
lineno = lineno + 1
|
||||||
|
|
||||||
|
# skip non-matching lines early
|
||||||
|
if line[0] != '#':
|
||||||
|
continue
|
||||||
|
|
||||||
headermatch = re.search(r'''^# *include *[<"]([^>"]*\.h)[">]''', line)
|
headermatch = re.search(r'''^# *include *[<"]([^>"]*\.h)[">]''', line)
|
||||||
if headermatch is not None:
|
if headermatch is not None:
|
||||||
inc = headermatch.group(1)
|
inc = headermatch.group(1)
|
||||||
|
Loading…
Reference in New Issue
Block a user