Data: use pre-defined output array length in vectorToArray() (#29516)

This commit is contained in:
Leon Sorokin 2020-12-02 09:34:44 -06:00 committed by GitHub
parent aa70a38391
commit 2c535a9583
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,7 @@
import { Vector } from '../types/vector';
export function vectorToArray<T>(v: Vector<T>): T[] {
const arr: T[] = [];
const arr: T[] = Array(v.length);
for (let i = 0; i < v.length; i++) {
arr[i] = v.get(i);
}