Commit ee427cb5 authored by Martijn Pieters's avatar Martijn Pieters

Refactor PathIndex search, reducing it's memory use somewhat.

parent 76a2f191
...@@ -177,32 +177,23 @@ class PathIndex(Persistent, SimpleItem): ...@@ -177,32 +177,23 @@ class PathIndex(Persistent, SimpleItem):
if len(comps) == 0: if len(comps) == 0:
return IISet(self._unindex.keys()) return IISet(self._unindex.keys())
results = None
if level >= 0: if level >= 0:
results = [] for i, comp in enumerate(comps):
for i in range(len(comps)):
comp = comps[i]
if not self._index.has_key(comp): return IISet() if not self._index.has_key(comp): return IISet()
if not self._index[comp].has_key(level+i): return IISet() if not self._index[comp].has_key(level+i): return IISet()
results.append( self._index[comp][level+i] ) results = intersection(results, self._index[comp][level+i])
res = results[0]
for i in range(1,len(results)):
res = intersection(res,results[i])
return res
else: else:
results = IISet() for level in range(self._depth + 1):
for level in range(0,self._depth + 1):
ids = None ids = None
error = 0 for i, comp in enumerate(comps):
for cn in range(0,len(comps)):
comp = comps[cn]
try: try:
ids = intersection(ids,self._index[comp][level+cn]) ids = intersection(ids, self._index[comp][level+i])
except KeyError: except KeyError:
error = 1 break
if error==0: else:
results = union(results,ids) results = union(results, ids)
return results return results
def numObjects(self): def numObjects(self):
......
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