[FIX] read: fix performance issue due to O(n)^2 sorting

bzr revid: fva@openerp.com-20140123161523-xvc8so45uwj3uivs
This commit is contained in:
Frédéric van der Essen 2014-01-23 17:15:23 +01:00
parent 27224c9b9e
commit 2f2c1057b3
1 changed files with 6 additions and 1 deletions

View File

@ -1084,7 +1084,12 @@ class DataSet(openerpweb.Controller):
}
records = Model.read(ids, fields or False, req.context)
records.sort(key=lambda obj: ids.index(obj['id']))
index = {}
for r in records:
index[r['id']] = r
records = [index[x] for x in ids if x in index]
return {
'length': length,
'records': records