[Erp5-report] r31509 nicolas.dumazet - /erp5/trunk/products/ERP5/Document/TradeCondition.py

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Dec 29 04:14:05 CET 2009


Author: nicolas.dumazet
Date: Tue Dec 29 04:14:04 2009
New Revision: 31509

URL: http://svn.erp5.org?rev=31509&view=rev
Log:
reverting r31508. Add a comment explaining why sets cant be used for a
cleaner algorithm

Modified:
    erp5/trunk/products/ERP5/Document/TradeCondition.py

Modified: erp5/trunk/products/ERP5/Document/TradeCondition.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/TradeCondition.py?rev=31509&r1=31508&r2=31509&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/TradeCondition.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/TradeCondition.py [utf8] Tue Dec 29 04:14:04 2009
@@ -148,15 +148,18 @@
           # it is possible, that specialised object cannot be specialised
           # anymore
           continue
-        difference = set(child_specialised_value_list).difference(\
+        # Use a set for faster lookups. We do not use sets everywhere
+        # because search order does matter
+        intersection = set(child_specialised_value_list).intersection(\
             set(visited_trade_condition_list))
-        # don't add model that have already been visited. This permit to
-        # visit all the tree and to prevent having circular dependency
-        for model in difference:
-          specialise_value_list.append(model)
-          # only add those who matches the portal type given
-          if model in child_visited_trade_condition_list:
-            visited_trade_condition_list.append(model)
+        for model in child_specialised_value_list:
+          # don't add model that have already been visited. This permit to
+          # visit all the tree and to prevent having circular dependency
+          if model not in intersection:
+            specialise_value_list.append(model)
+            # only add those who matches the portal type given
+            if model in child_visited_trade_condition_list:
+              visited_trade_condition_list.append(model)
 
       return visited_trade_condition_list
 




More information about the Erp5-report mailing list