mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
scripts: check-aclrules: use in instead of find
For checking whether a substring is present in a string, using the pattern: "str" in string is slightly faster than: string.find("str") != -1 Use it to shave off 4 % of the runtime of this script that processes quite a few long source files. 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
424a385c3a
commit
988f02a99c
@ -97,7 +97,7 @@ def fixup_name(name):
|
|||||||
|
|
||||||
def name_to_ProcName(name):
|
def name_to_ProcName(name):
|
||||||
elems = []
|
elems = []
|
||||||
if name.find("_") != -1 or name.lower() in ["open", "close"]:
|
if "_" in name or name.lower() in ["open", "close"]:
|
||||||
elems = [n.lower().capitalize() for n in name.split("_")]
|
elems = [n.lower().capitalize() for n in name.split("_")]
|
||||||
else:
|
else:
|
||||||
elems = [name]
|
elems = [name]
|
||||||
@ -116,11 +116,11 @@ with open(proto, "r") as fh:
|
|||||||
filtered = False
|
filtered = False
|
||||||
|
|
||||||
for line in fh:
|
for line in fh:
|
||||||
if line.find("/**") != -1:
|
if "/**" in line:
|
||||||
incomment = True
|
incomment = True
|
||||||
filtered = False
|
filtered = False
|
||||||
elif incomment:
|
elif incomment:
|
||||||
if line.find("* @aclfilter") != -1:
|
if "* @aclfilter" in line:
|
||||||
filtered = True
|
filtered = True
|
||||||
elif filtered:
|
elif filtered:
|
||||||
m = re.search(r'''REMOTE_PROC_(.*)\s+=\s*\d+''', line)
|
m = re.search(r'''REMOTE_PROC_(.*)\s+=\s*\d+''', line)
|
||||||
@ -211,7 +211,7 @@ def process_file(filename):
|
|||||||
# an ACL function
|
# an ACL function
|
||||||
if intable:
|
if intable:
|
||||||
assign = re.search(r'''\.(\w+)\s*=\s*(\w+),?''', line)
|
assign = re.search(r'''\.(\w+)\s*=\s*(\w+),?''', line)
|
||||||
if line.find("}") != -1:
|
if "}" in line:
|
||||||
intable = False
|
intable = False
|
||||||
table = None
|
table = None
|
||||||
elif assign is not None:
|
elif assign is not None:
|
||||||
@ -247,9 +247,9 @@ def process_file(filename):
|
|||||||
intable = True
|
intable = True
|
||||||
table = name
|
table = name
|
||||||
|
|
||||||
if line.find("{") != -1:
|
if "{" in line:
|
||||||
brace = brace + 1
|
brace = brace + 1
|
||||||
if line.find("}") != -1:
|
if "}" in line:
|
||||||
brace = brace - 1
|
brace = brace - 1
|
||||||
|
|
||||||
return errs
|
return errs
|
||||||
|
Loading…
Reference in New Issue
Block a user