mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 14:22:46 +00: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:
@@ -154,7 +154,7 @@ def keysum(module, gs, bucket, obj):
|
||||
key_check = bucket.get_key(obj)
|
||||
if key_check:
|
||||
md5_remote = key_check.etag[1:-1]
|
||||
etag_multipart = md5_remote.find('-')!=-1 #Check for multipart, etag is not md5
|
||||
etag_multipart = '-' in md5_remote # Check for multipart, etag is not md5
|
||||
if etag_multipart is True:
|
||||
module.fail_json(msg="Files uploaded with multipart of gs are not supported with checksum, unable to compute checksum.")
|
||||
return md5_remote
|
||||
|
||||
@@ -147,7 +147,7 @@ def keysum(module, s3, bucket, obj):
|
||||
key_check = bucket.get_key(obj)
|
||||
if key_check:
|
||||
md5_remote = key_check.etag[1:-1]
|
||||
etag_multipart = md5_remote.find('-')!=-1 #Check for multipart, etag is not md5
|
||||
etag_multipart = '-' in md5_remote # Check for multipart, etag is not md5
|
||||
if etag_multipart is True:
|
||||
module.fail_json(msg="Files uploaded with multipart of s3 are not supported with checksum, unable to compute checksum.")
|
||||
return md5_remote
|
||||
|
||||
Reference in New Issue
Block a user