perf: don't create holey arrays (#32155)
Don't use `Array` constructor with the size value (ex. `new Array(5)`) - this will create a `HOLEY_ELEMENTS` array (even if this array is filled in later on!); https://v8.dev/blog/elements-kinds https://stackoverflow.com/questions/32054170/how-to-resize-an-array PR Close #32155
This commit is contained in:

committed by
Andrew Kushnir

parent
c957dfc167
commit
64770571b2
@ -24,7 +24,7 @@ import {ProviderElementContext, ProviderViewContext} from '../provider_analyzer'
|
||||
import {ElementSchemaRegistry} from '../schema/element_schema_registry';
|
||||
import {CssSelector, SelectorMatcher} from '../selector';
|
||||
import {isStyleUrlResolvable} from '../style_url_resolver';
|
||||
import {Console, syntaxError} from '../util';
|
||||
import {Console, newArray, syntaxError} from '../util';
|
||||
|
||||
import {BindingParser} from './binding_parser';
|
||||
import * as t from './template_ast';
|
||||
@ -528,7 +528,7 @@ class TemplateParseVisitor implements html.Visitor {
|
||||
// Need to sort the directives so that we get consistent results throughout,
|
||||
// as selectorMatcher uses Maps inside.
|
||||
// Also deduplicate directives as they might match more than one time!
|
||||
const directives = new Array(this.directivesIndex.size);
|
||||
const directives = newArray(this.directivesIndex.size);
|
||||
// Whether any directive selector matches on the element name
|
||||
let matchElement = false;
|
||||
|
||||
|
Reference in New Issue
Block a user