Commit efe97eca authored by Vincent Pelletier's avatar Vincent Pelletier

Improve code readability by removing some "continue"s.

Tiny inner loop optimisation on list append.
Remvoe unneeded (obvious) comments.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@649 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 04001b76
...@@ -841,39 +841,28 @@ class Application(object): ...@@ -841,39 +841,28 @@ class Application(object):
logging.info("UndoLog, tids %s", ordered_tids) logging.info("UndoLog, tids %s", ordered_tids)
# For each transaction, get info # For each transaction, get info
undo_info = [] undo_info = []
append = undo_info.append
for tid in ordered_tids: for tid in ordered_tids:
cell_list = self._getCellListForID(tid, readable=True) cell_list = self._getCellListForID(tid, readable=True)
shuffle(cell_list) shuffle(cell_list)
for cell in cell_list: for cell in cell_list:
conn = self.cp.getConnForCell(cell) conn = self.cp.getConnForCell(cell)
if conn is None: if conn is not None:
continue
self.local_var.txn_info = 0 self.local_var.txn_info = 0
try: try:
self._askStorage(conn, protocol.askTransactionInformation(tid)) self._askStorage(conn, protocol.askTransactionInformation(tid))
except NEOStorageConnectionFailure: except NEOStorageConnectionFailure:
continue continue
if isinstance(self.local_var.txn_info, dict):
if self.local_var.txn_info == -1:
# TID not found, go on with next node
continue
elif isinstance(self.local_var.txn_info, dict):
break break
if self.local_var.txn_info in (-1, 0): if self.local_var.txn_info in (-1, 0):
# TID not found at all # TID not found at all
continue continue
# Filter result if needed if filter is None or filter(self.local_var.txn_info):
if filter is not None:
# Filter method return True if match
if not filter(self.local_var.txn_info):
continue
# Append to returned list
self.local_var.txn_info.pop("oids") self.local_var.txn_info.pop("oids")
undo_info.append(self.local_var.txn_info) append(self.local_var.txn_info)
if len(undo_info) >= last - first: if len(undo_info) >= last - first:
break break
# Check we return at least one element, otherwise call # Check we return at least one element, otherwise call
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment