[FIX] website: sitemap scalability
Checking url_list for duplicates is O(n). Use url_set instead of url_list to improve to O(1). Otherwise sitemap generation even for a million products will never finish. Close #11106
This commit is contained in:
parent
cfcf8bb318
commit
1d269d20f2
|
@ -384,7 +384,7 @@ class website(osv.osv):
|
|||
"""
|
||||
router = request.httprequest.app.get_db_router(request.db)
|
||||
# Force enumeration to be performed as public user
|
||||
url_list = []
|
||||
url_set = set()
|
||||
for rule in router.iter_rules():
|
||||
if not self.rule_is_enumerable(rule):
|
||||
continue
|
||||
|
@ -416,9 +416,9 @@ class website(osv.osv):
|
|||
page[key[2:]] = val
|
||||
if url in ('/sitemap.xml',):
|
||||
continue
|
||||
if url in url_list:
|
||||
if url in url_set:
|
||||
continue
|
||||
url_list.append(url)
|
||||
url_set.add(url)
|
||||
|
||||
yield page
|
||||
|
||||
|
|
Loading…
Reference in New Issue