Commit 2e3f7f91 authored by Nicolas Dumazet's avatar Nicolas Dumazet

use a set to avoid linear list lookups


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32737 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8bb8e68a
...@@ -635,7 +635,7 @@ class XMLMatrix(Folder): ...@@ -635,7 +635,7 @@ class XMLMatrix(Folder):
Constraint API. Constraint API.
""" """
# Check useless cells # Check useless cells
to_delete = [] to_delete_set = set()
error_list = [] error_list = []
def addError(message): def addError(message):
if fixit: if fixit:
...@@ -679,8 +679,7 @@ class XMLMatrix(Folder): ...@@ -679,8 +679,7 @@ class XMLMatrix(Folder):
if not self.index.has_key(base_id): if not self.index.has_key(base_id):
# The matrix does not have this base_id # The matrix does not have this base_id
addError("There is no index for base_id %s" % base_id) addError("There is no index for base_id %s" % base_id)
if object_id not in to_delete: to_delete_set.add(object_id)
to_delete.append(object_id)
else: else:
# Check empty indices. # Check empty indices.
empty_list = [] empty_list = []
...@@ -698,17 +697,15 @@ class XMLMatrix(Folder): ...@@ -698,17 +697,15 @@ class XMLMatrix(Folder):
if len(object_id_split) != (len_id + base_id_len): # +1 for the quantity if len(object_id_split) != (len_id + base_id_len): # +1 for the quantity
addError("Dimension of cell is %s but should be %s" % (len(object_id_split) addError("Dimension of cell is %s but should be %s" % (len(object_id_split)
- base_id_len, len_id)) - base_id_len, len_id))
if object_id not in to_delete: to_delete_set.add(object_id)
to_delete.append(object_id)
else : else :
for i in range(len_id): for i in range(len_id):
if int(object_id_split[i+base_id_len]) >= len(self.index[base_id][i]): if int(object_id_split[i+base_id_len]) >= len(self.index[base_id][i]):
addError("Cell %s is out of bound" % object_id) addError("Cell %s is out of bound" % object_id)
if object_id not in to_delete: to_delete_set.add(object_id)
to_delete.append(object_id)
if fixit and len(to_delete) > 0: if fixit and len(to_delete_set) > 0:
self.manage_delObjects(to_delete) self.manage_delObjects(list(to_delete_set))
return error_list return error_list
......
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