[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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user