提交 65366bd9 编写于 作者: J Ján Tomko

scripts: check-aclrules: use regular expressions less often

Use a simple
  if "substr" in line
before running a regular expression, which saves time,
especially if the regex has a capture group.

This reduces runtime of the check by almost 78 % for me.
Signed-off-by: NJán Tomko <jtomko@redhat.com>
Reviewed-by: NDaniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: NErik Skultety <eskultet@redhat.com>
上级 988f02a9
......@@ -150,12 +150,20 @@ def process_file(filename):
# Looks for anything which appears to be a function
# body name. Doesn't matter if we pick up bogus stuff
# here, as long as we don't miss valid stuff
m = None
if "(" in line:
m = re.search(r'''\b(\w+)\(''', line)
if m is not None:
maybefunc = m.group(1)
elif brace > 0:
ensureacl = None
checkacl = None
stub = None
if "EnsureACL" in line:
ensureacl = re.search(r'''(\w+)EnsureACL''', line)
if "CheckACL" in line:
checkacl = re.search(r'''(\w+)CheckACL''', line)
if "(" in line:
stub = re.search(r'''\b(\w+)\(''', line)
if ensureacl is not None:
# Record the fact that maybefunc contains an
......@@ -210,6 +218,8 @@ def process_file(filename):
# every func listed there, has an impl which calls
# an ACL function
if intable:
assign = None
if "=" in line:
assign = re.search(r'''\.(\w+)\s*=\s*(\w+),?''', line)
if "}" in line:
intable = False
......@@ -237,6 +247,8 @@ def process_file(filename):
file=sys.stderr)
errs = True
else:
m = None
if "Driver" in line:
m = re.search(r'''^(?:static\s+)?(vir(?:\w+)?Driver)\s+''',
line)
if m is not None:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册