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,41 +841,30 @@ class Application(object): ...@@ -841,41 +841,30 @@ 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
try:
self.local_var.txn_info = 0 self._askStorage(conn, protocol.askTransactionInformation(tid))
try: except NEOStorageConnectionFailure:
self._askStorage(conn, protocol.askTransactionInformation(tid)) continue
except NEOStorageConnectionFailure: if isinstance(self.local_var.txn_info, dict):
continue break
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
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: self.local_var.txn_info.pop("oids")
# Filter method return True if match append(self.local_var.txn_info)
if not filter(self.local_var.txn_info): if len(undo_info) >= last - first:
continue break
# Append to returned list
self.local_var.txn_info.pop("oids")
undo_info.append(self.local_var.txn_info)
if len(undo_info) >= last - first:
break
# Check we return at least one element, otherwise call # Check we return at least one element, otherwise call
# again but extend offset # again but extend offset
if len(undo_info) == 0 and not block: if len(undo_info) == 0 and not block:
......
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