mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 20:01:25 -07:00
Micro-optimization: replace s.find(x)!=-1 with x in s
timeit shows a speedup of ~3x on Python 2.7.5 x86_64. It also makes the code a bit shorter.
This commit is contained in:
parent
a7da5d8702
commit
0749112286
19 changed files with 50 additions and 48 deletions
|
@ -331,7 +331,7 @@ class ActionModule(object):
|
|||
src = open(source)
|
||||
src_contents = src.read(8192)
|
||||
st = os.stat(source)
|
||||
if src_contents.find("\x00") != -1:
|
||||
if "\x00" in src_contents:
|
||||
diff['src_binary'] = 1
|
||||
elif st[stat.ST_SIZE] > utils.MAX_FILE_SIZE_FOR_DIFF:
|
||||
diff['src_larger'] = utils.MAX_FILE_SIZE_FOR_DIFF
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue