From 7f2db6758ec4baf66f5750ec918736b2245a76f2 Mon Sep 17 00:00:00 2001 From: Kazuhiko Shiozaki <kazuhiko@nexedi.com> Date: Fri, 26 Sep 2008 21:22:05 +0000 Subject: [PATCH] use sort(key=) instead of sort(cmp=) for better performance. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23852 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../erp5_core/Category_getSortedCategoryChildValueList.xml | 2 +- .../portal_skins/erp5_core/ERP5Site_getModuleItemList.xml | 2 +- .../portal_skins/erp5_core/ListBox_initializeFastInput.xml | 2 +- .../erp5_core/RamCache_getCachePluginStatisticList.xml | 2 +- product/ERP5/bootstrap/erp5_core/bt/revision | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Category_getSortedCategoryChildValueList.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Category_getSortedCategoryChildValueList.xml index ab36e99041..27a15282c4 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Category_getSortedCategoryChildValueList.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Category_getSortedCategoryChildValueList.xml @@ -59,7 +59,7 @@ log(\'Category_getSortedCategoryChildValueList\', \'use getCategoryChildValueLis \n value_list = filter(lambda o: o.getRelativeUrl() != context.getRelativeUrl(),context.getCategoryChildValueList())\n sort_id=\'int_index\'\n -value_list.sort(lambda x,y: cmp(x.getProperty(sort_id), y.getProperty(sort_id)))\n +value_list.sort(key=lambda x: x.getProperty(sort_id))\n return value_list\n </string> </value> </item> diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Site_getModuleItemList.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Site_getModuleItemList.xml index 1fc202ee06..7dfcf979a0 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Site_getModuleItemList.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Site_getModuleItemList.xml @@ -68,7 +68,7 @@ def getModuleItemList(user=None):\n if portal.portal_membership.checkPermission(\'View\', module):\n item_list.append((gettext(module.getTitleOrId()), module.absolute_url_path()))\n \n - item_list.sort(lambda a, b:cmp(a[0], b[0]))\n + item_list.sort(key=lambda x: x[0])\n return item_list\n \n getModuleItemList = CachingMethod(getModuleItemList, \n diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ListBox_initializeFastInput.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ListBox_initializeFastInput.xml index 57815dae1a..09716521fc 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ListBox_initializeFastInput.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ListBox_initializeFastInput.xml @@ -76,7 +76,7 @@ if hasattr(request, \'listbox\'):\n keys_list = listbox.keys()\n \n if keys_list != []:\n - keys_list.sort(lambda x,y: cmp(int(x),int(y)))\n + keys_list.sort(key=lambda x: int(x))\n first_empty_line_id = int(keys_list[-1])+1\n \n for i in keys_list:\n diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/RamCache_getCachePluginStatisticList.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/RamCache_getCachePluginStatisticList.xml index 30a0e3da5d..f77c593a0f 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/RamCache_getCachePluginStatisticList.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/RamCache_getCachePluginStatisticList.xml @@ -85,7 +85,7 @@ for cache_key,cache_key_memory in cache_plugin_stats_data.items():\n # sort result\n if kw.get(\'sort_on\', None) is not None:\n sort_on_attr, sort_on_order = kw[\'sort_on\'][0]\n - result.sort(lambda x,y: cmp(int(getattr(x, sort_on_attr)), int(getattr(y, sort_on_attr))))\n + result.sort(key=lambda x: int(getattr(x, sort_on_attr)))\n if sort_on_order == \'descending\':\n result.reverse()\n \n diff --git a/product/ERP5/bootstrap/erp5_core/bt/revision b/product/ERP5/bootstrap/erp5_core/bt/revision index 25c83294f5..8f32b0ba57 100644 --- a/product/ERP5/bootstrap/erp5_core/bt/revision +++ b/product/ERP5/bootstrap/erp5_core/bt/revision @@ -1 +1 @@ -968 \ No newline at end of file +969 \ No newline at end of file -- 2.30.9