Commit 12c2e965 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

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.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@29762 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fecbb25e
......@@ -427,7 +427,9 @@ class ERP5Site(FolderMixIn, CMFSite):
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')
......
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