From Dan Kenigsberg <[email protected]>: Dan Kenigsberg has uploaded a new change for review.
Change subject: storage_persistentdict: simplify code by using sorted() ...................................................................... storage_persistentdict: simplify code by using sorted() The intention was to make this code compliant with Python 3, but the outcome is cleaner, regardless. On its own, sorted() adds a redundant copy of a list, but this copy replaces an existing copy that was happening inside the keys() call. Change-Id: I9732157a410735c14d4f5f8d87249b2c77ecb04c Signed-off-by: Dan Kenigsberg <[email protected]> --- M lib/vdsm/storage/persistent.py 1 file changed, 3 insertions(+), 6 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/00/73100/1 diff --git a/lib/vdsm/storage/persistent.py b/lib/vdsm/storage/persistent.py index 09682a3..be853de 100644 --- a/lib/vdsm/storage/persistent.py +++ b/lib/vdsm/storage/persistent.py @@ -32,6 +32,7 @@ import threading from copy import deepcopy +import six from six.moves import filter as ifilter SHA_CKSUM_TAG = "_SHA_CKSUM" @@ -268,9 +269,7 @@ return checksumCalculator = hashlib.sha1() - keys = newMD.keys() - keys.sort() - for key in keys: + for key in sorted(six.iterkeys(newMD)): value = newMD[key] line = "%s=%s" % (key, value) checksumCalculator.update(_preprocessLine(line)) @@ -292,9 +291,7 @@ checksumCalculator = hashlib.sha1() lines = [] - keys = md.keys() - keys.sort() - for key in keys: + for key in sorted(six.iterkeys(md)): value = md[key] line = "=".join([key, value.strip()]) checksumCalculator.update(_preprocessLine(line)) -- To view, visit https://gerrit.ovirt.org/73100 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9732157a410735c14d4f5f8d87249b2c77ecb04c Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Dan Kenigsberg <[email protected]> _______________________________________________ vdsm-patches mailing list -- [email protected] To unsubscribe send an email to [email protected]
