From 706878b9b4490ec5165d2ea20662093e9f7cecfc Mon Sep 17 00:00:00 2001
From: Julien Muchembled <jm@nexedi.com>
Date: Thu, 21 Apr 2016 21:16:09 +0200
Subject: [PATCH] ERP5Site: minor optimization in some getPortal*TypeList
 methods

We could go further by changing the API to not cast the result into tuples.
---
 product/ERP5/ERP5Site.py | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/product/ERP5/ERP5Site.py b/product/ERP5/ERP5Site.py
index e78a93221e..aff4952e9e 100644
--- a/product/ERP5/ERP5Site.py
+++ b/product/ERP5/ERP5Site.py
@@ -1087,10 +1087,11 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
     """
       Return acquisition movement types.
     """
-    return tuple(list(self.getPortalOrderMovementTypeList()) +
-                 list(self.getPortalDeliveryMovementTypeList()) +
-                 list(self.getPortalTaxMovementTypeList()) +
-                 list(self.getPortalInvoiceMovementTypeList()))
+    r = list(self.getPortalOrderMovementTypeList())
+    r += self.getPortalDeliveryMovementTypeList()
+    r += self.getPortalTaxMovementTypeList()
+    r += self.getPortalInvoiceMovementTypeList()
+    return tuple(r)
 
   security.declareProtected(Permissions.AccessContentsInformation,
                             'getPortalMovementTypeList')
@@ -1098,12 +1099,13 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
     """
       Return movement types.
     """
-    return tuple(list(self.getPortalOrderMovementTypeList()) +
-                 list(self.getPortalDeliveryMovementTypeList()) +
-                 list(self.getPortalInvoiceMovementTypeList()) +
-                 list(self.getPortalTaxMovementTypeList()) +
-                 list(self.getPortalAccountingMovementTypeList()) +
-                 ['Simulation Movement'])
+    r = list(self.getPortalOrderMovementTypeList())
+    r += self.getPortalDeliveryMovementTypeList()
+    r += self.getPortalInvoiceMovementTypeList()
+    r += self.getPortalTaxMovementTypeList()
+    r += self.getPortalAccountingMovementTypeList()
+    r.append('Simulation Movement')
+    return tuple(r)
 
   security.declareProtected(Permissions.AccessContentsInformation,
                             'getPortalSimulatedMovementTypeList')
@@ -1111,8 +1113,9 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
     """
       Return simulated movement types.
     """
-    return tuple([x for x in self.getPortalMovementTypeList() \
-                  if x not in self.getPortalContainerTypeList()])
+    r = set(self.getPortalMovementTypeList())
+    r.difference_update(self.getPortalContainerTypeList())
+    return tuple(r)
 
   security.declareProtected(Permissions.AccessContentsInformation,
                             'getPortalContainerTypeList')
-- 
2.30.9