mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 01:18:00 +03:00
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: 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
988f02a99c
commit
65366bd960
@ -150,13 +150,21 @@ def process_file(filename):
|
|||||||
# Looks for anything which appears to be a function
|
# Looks for anything which appears to be a function
|
||||||
# body name. Doesn't matter if we pick up bogus stuff
|
# body name. Doesn't matter if we pick up bogus stuff
|
||||||
# here, as long as we don't miss valid stuff
|
# here, as long as we don't miss valid stuff
|
||||||
m = re.search(r'''\b(\w+)\(''', line)
|
m = None
|
||||||
|
if "(" in line:
|
||||||
|
m = re.search(r'''\b(\w+)\(''', line)
|
||||||
if m is not None:
|
if m is not None:
|
||||||
maybefunc = m.group(1)
|
maybefunc = m.group(1)
|
||||||
elif brace > 0:
|
elif brace > 0:
|
||||||
ensureacl = re.search(r'''(\w+)EnsureACL''', line)
|
ensureacl = None
|
||||||
checkacl = re.search(r'''(\w+)CheckACL''', line)
|
checkacl = None
|
||||||
stub = re.search(r'''\b(\w+)\(''', line)
|
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:
|
if ensureacl is not None:
|
||||||
# Record the fact that maybefunc contains an
|
# Record the fact that maybefunc contains an
|
||||||
# ACL call, and make sure it is the right call!
|
# ACL call, and make sure it is the right call!
|
||||||
@ -210,7 +218,9 @@ def process_file(filename):
|
|||||||
# every func listed there, has an impl which calls
|
# every func listed there, has an impl which calls
|
||||||
# an ACL function
|
# an ACL function
|
||||||
if intable:
|
if intable:
|
||||||
assign = re.search(r'''\.(\w+)\s*=\s*(\w+),?''', line)
|
assign = None
|
||||||
|
if "=" in line:
|
||||||
|
assign = re.search(r'''\.(\w+)\s*=\s*(\w+),?''', line)
|
||||||
if "}" in line:
|
if "}" in line:
|
||||||
intable = False
|
intable = False
|
||||||
table = None
|
table = None
|
||||||
@ -237,8 +247,10 @@ def process_file(filename):
|
|||||||
file=sys.stderr)
|
file=sys.stderr)
|
||||||
errs = True
|
errs = True
|
||||||
else:
|
else:
|
||||||
m = re.search(r'''^(?:static\s+)?(vir(?:\w+)?Driver)\s+''',
|
m = None
|
||||||
line)
|
if "Driver" in line:
|
||||||
|
m = re.search(r'''^(?:static\s+)?(vir(?:\w+)?Driver)\s+''',
|
||||||
|
line)
|
||||||
if m is not None:
|
if m is not None:
|
||||||
name = m.group(1)
|
name = m.group(1)
|
||||||
if name not in ["virNWFilterCallbackDriver",
|
if name not in ["virNWFilterCallbackDriver",
|
||||||
|
Loading…
Reference in New Issue
Block a user