From 48d73a1ead248a2f9eab510c5d462aa7ab72f061 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Theys?= Date: Thu, 7 Dec 2023 15:23:09 +0100 Subject: [PATCH] [FIX] web: improve perf of matchDomain `operators` object only contains 3 specific strings as key, and most domain items are arrays. Checking the type of the item to avoid a costly and failing `in` check, as well as using direct key access, allows gaining a lot of time. The method going from 60ms to 6ms when running the test "Load 100 recipients at once" on my machine, and the specific line tends to 0ms. Part-of: odoo/odoo#145442 --- addons/web/static/src/core/domain.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/core/domain.js b/addons/web/static/src/core/domain.js index bad87558572..633f30653bb 100644 --- a/addons/web/static/src/core/domain.js +++ b/addons/web/static/src/core/domain.js @@ -422,8 +422,8 @@ function matchDomain(record, domain) { const reversedDomain = Array.from(domain).reverse(); const condStack = []; for (const item of reversedDomain) { - if (item in operators) { - const operator = operators[item]; + const operator = typeof item === "string" && operators[item]; + if (operator) { const operands = condStack.splice(-operator.length); condStack.push(operator(...operands)); } else {