mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-31 00:45:18 +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:
|
||||
lineno = lineno + 1
|
||||
|
||||
# skip non-matching lines early
|
||||
if line[0] != '#':
|
||||
continue
|
||||
|
||||
headermatch = re.search(r'''^# *include *[<"]([^>"]*\.h)[">]''', line)
|
||||
if headermatch is not None:
|
||||
inc = headermatch.group(1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user