[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
This commit is contained in:
Sébastien Theys
2023-12-08 15:57:52 +00:00
parent ba37217944
commit 48d73a1ead
+2 -2
View File
@@ -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 {