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
@ -75,7 +75,7 @@ class MultiplyDirectiveResolver extends DirectiveResolver {
|
||||
|
||||
private _fillCache(component: Type) {
|
||||
const view = super.resolve(component);
|
||||
const multipliedTemplates = new Array(this._multiplyBy);
|
||||
const multipliedTemplates = [];
|
||||
for (let i = 0; i < this._multiplyBy; ++i) {
|
||||
multipliedTemplates[i] = view.template;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ let testList = null;
|
||||
|
||||
export function main() {
|
||||
const size = getIntParameter('size');
|
||||
testList = new Array(size);
|
||||
testList = [];
|
||||
|
||||
platformBrowserDynamic().bootstrapModule(AppModule).then((ref) => {
|
||||
const injector = ref.injector;
|
||||
|
Reference in New Issue
Block a user