[Erp5-report] r29762 - /erp5/trunk/products/ERP5/ERP5Site.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Oct 16 15:00:34 CEST 2009


Author: kazuhiko
Date: Fri Oct 16 15:00:32 2009
New Revision: 29762

URL: http://svn.erp5.org?rev=29762&view=rev
Log:
modify r29751.
* try to sort only if it is required, because Localizer.translate() is much slower than len(list) and sort(key=...) will call key function even if the list has only one item.

Modified:
    erp5/trunk/products/ERP5/ERP5Site.py

Modified: erp5/trunk/products/ERP5/ERP5Site.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/ERP5Site.py?rev=29762&r1=29761&r2=29762&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/ERP5Site.py [utf8] (original)
+++ erp5/trunk/products/ERP5/ERP5Site.py [utf8] Fri Oct 16 15:00:32 2009
@@ -427,7 +427,9 @@
         if group in getattr(pt, 'group_list', ()):
           type_list.append(pt.getId())
 
-      type_list.sort(key=lambda x:localizer_tool.translate('ui', x))
+      if len(type_list) >= 2:
+        translate = localizer_tool.translate
+        type_list.sort(key=lambda x:translate('ui', x))
       return tuple(type_list)
 
     localizer_tool = getToolByName(self, 'Localizer')




More information about the Erp5-report mailing list