From 5626fc643f79a201c2b3c21d8d111e37a3a3c519 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Mon, 19 Aug 2019 10:55:22 +0200 Subject: [PATCH] perfs: use a dictionary to create sorted list of formdatas (#35437) --- wcs/forms/backoffice.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/wcs/forms/backoffice.py b/wcs/forms/backoffice.py index 3c4a377e5..9ed615975 100644 --- a/wcs/forms/backoffice.py +++ b/wcs/forms/backoffice.py @@ -166,11 +166,8 @@ class FormDefUI(object): order_by = None if order_by and not anonymise: ordered_ids = formdata_class.get_sorted_ids(order_by) - new_item_ids = [] - for item_id in ordered_ids: - if item_id in item_ids: - new_item_ids.append(item_id) - item_ids = new_item_ids + item_ids_dict = {x: True for x in item_ids} + item_ids = [x for x in ordered_ids if x in item_ids_dict] else: item_ids.sort(lambda x,y: cmp(int(x), int(y))) item_ids.reverse()