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
@ -19,7 +19,7 @@ import {JitReflector} from '@angular/platform-browser-dynamic/src/compiler_refle
|
||||
import {CompileEntryComponentMetadata, CompileStylesheetMetadata} from '../../src/compile_metadata';
|
||||
import {Identifiers, createTokenForExternalReference, createTokenForReference} from '../../src/identifiers';
|
||||
import {DEFAULT_INTERPOLATION_CONFIG, InterpolationConfig} from '../../src/ml_parser/interpolation_config';
|
||||
import {noUndefined} from '../../src/util';
|
||||
import {newArray, noUndefined} from '../../src/util';
|
||||
import {MockSchemaRegistry} from '../../testing';
|
||||
import {unparse} from '../expression_parser/utils/unparser';
|
||||
import {TEST_COMPILER_PROVIDERS} from '../test_bindings';
|
||||
@ -481,7 +481,7 @@ class ArrayConsole implements Console {
|
||||
new BoundDirectivePropertyAst('foo', 'bar', null !, null !)
|
||||
];
|
||||
const result = templateVisitAll(visitor, nodes, null);
|
||||
expect(result).toEqual(new Array(nodes.length).fill(true));
|
||||
expect(result).toEqual(newArray(nodes.length).fill(true));
|
||||
});
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user