提交 424a385c 编写于 作者: J Ján Tomko

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: NJán Tomko <jtomko@redhat.com>
Reviewed-by: NDaniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: NErik Skultety <eskultet@redhat.com>
上级 05d28fac
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册