Commit a7fb5cc4 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Optimization.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3229 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d855e4bc
...@@ -515,10 +515,12 @@ class XMLMatrix(Folder): ...@@ -515,10 +515,12 @@ class XMLMatrix(Folder):
return () return ()
if not self.index.has_key(base_id): if not self.index.has_key(base_id):
return () return ()
index = self.index[base_id]
id_tuple = [] id_tuple = []
for i in range(0, len(self.index[base_id].keys())): extend = id_tuple.extend
t = self.index[base_id][i] for i in xrange(0, len(index)):
id_tuple += [t.keys()] t = index[i]
extend(t.keys())
if len(id_tuple) == 0: if len(id_tuple) == 0:
return () return ()
return cartesianProduct(id_tuple) return cartesianProduct(id_tuple)
...@@ -535,15 +537,15 @@ class XMLMatrix(Folder): ...@@ -535,15 +537,15 @@ class XMLMatrix(Folder):
""" """
Converts a key into an id Converts a key into an id
""" """
cell_id = base_id index = self.index[base_id]
i = 0 cell_id_list = [base_id]
for my_id in kw: append = cell_id_list.append
if self.index[base_id][i].has_key(my_id): for i in xrange(len(kw)):
cell_id += '_%s' % self.index[base_id][i][my_id] try:
else: append(index[i][kw[i]])
cell_id = None except KeyError:
i += 1 return None
return cell_id return '_'.join(cell_id_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getCellIdList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getCellIdList' )
def getCellIdList(self, base_id = 'cell'): def getCellIdList(self, base_id = 'cell'):
...@@ -555,11 +557,11 @@ class XMLMatrix(Folder): ...@@ -555,11 +557,11 @@ class XMLMatrix(Folder):
if not self.index.has_key(base_id): if not self.index.has_key(base_id):
return () return ()
result = [] result = []
append = result.append
for kw in self.getCellKeys(base_id = base_id): for kw in self.getCellKeys(base_id = base_id):
cell_id = self.keyToId(kw, base_id = base_id ) cell_id = self.keyToId(kw, base_id = base_id )
if cell_id is not None: if cell_id is not None:
result += [cell_id] append(cell_id)
return result return result
......
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