Commit 47fbbd53 authored by Julien Muchembled's avatar Julien Muchembled

Small optimizations

git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/amount_generator@37909 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c996e3e2
...@@ -588,18 +588,12 @@ class SimulationMovement(PropertyRecordableMixin, Movement, ExplainableMixin): ...@@ -588,18 +588,12 @@ class SimulationMovement(PropertyRecordableMixin, Movement, ExplainableMixin):
# #
# store a causality -> causality_related_movement_list mapping # store a causality -> causality_related_movement_list mapping
causality_dict = dict() causality_dict = {}
current = self.getParentValue().getParentValue()
current = self.getParentValue() while current.getPortalType() == "Simulation Movement":
while True:
portal_type = current.getPortalType()
if portal_type == "Simulation Movement":
causality_dict[current.getCausality(portal_type='Business Link')] = \ causality_dict[current.getCausality(portal_type='Business Link')] = \
current current
elif portal_type != "Applied Rule": current = current.getParentValue().getParentValue()
break
# XXX or maybe directly go up by two levels?
current = current.getParentValue()
remaining_path_set = set() remaining_path_set = set()
for path in predecessor_path_list: for path in predecessor_path_list:
......
...@@ -185,27 +185,26 @@ class ExplanationCache: ...@@ -185,27 +185,26 @@ class ExplanationCache:
kw_tuple = tuple(kw.items()) # We hope that no sorting is needed kw_tuple = tuple(kw.items()) # We hope that no sorting is needed
def getParentSimulationMovementValueList(obj, movement_list, trade_phase): def getParentSimulationMovementValueList(obj, movement_list, trade_phase):
if getattr(obj, "getParentValue", None):
parent = obj.getParentValue() parent = obj.getParentValue()
if parent is not None: while parent.getPortalType() == "Simulation Movement":
if parent.getPortalType() == "Simulation Movement" and \ if parent.getCausalityValue(
parent.getCausalityValue().isMemberOf(trade_phase, strict_membership=1): ).isMemberOf(trade_phase, strict_membership=1):
movement_list.append(parent) movement_list.append(parent)
getParentSimulationMovementValueList(parent, movement_list, trade_phase) parent = parent.getParentValue().getParentValue()
def getChildSimulationMovementValueList(obj, movement_list, trade_phase): def getChildSimulationMovementValueList(obj, movement_list, trade_phase):
child_list = obj.objectValues() for child in obj.objectValues():
for child in child_list: if (child.getPortalType() == "Simulation Movement" and
if child.getPortalType() == "Simulation Movement" and \ child.getCausalityValue(
child.getCausalityValue().isMemberOf(trade_phase, strict_membership=1): ).isMemberOf(trade_phase, strict_membership=1)):
movement_list.append(child) movement_list.append(child)
getChildSimulationMovementValueList(child, movement_list, trade_phase) getChildSimulationMovementValueList(child, movement_list, trade_phase)
if self.simulation_movement_cache.get(kw_tuple, None) is None: if kw_tuple not in self.simulation_movement_cache:
if self.explanation.getPortalType() == "Applied Rule": if self.explanation.getPortalType() == "Applied Rule":
movement_list = [] movement_list = []
getParentSimulationMovementValueList(self.explanation, movement_list, kw.get('trade_phase', None)) getParentSimulationMovementValueList(self.explanation, movement_list, kw['trade_phase'])
getChildSimulationMovementValueList(self.explanation, movement_list, kw.get('trade_phase', None)) getChildSimulationMovementValueList(self.explanation, movement_list, kw['trade_phase'])
self.simulation_movement_cache[kw_tuple] = movement_list self.simulation_movement_cache[kw_tuple] = movement_list
else: else:
# XXX-Aurel : the following code seems not working as expected, it returns # XXX-Aurel : the following code seems not working as expected, it returns
......
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