You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-07 10:46:24 +03:00
Merge pull request #6360 from matrix-org/travis/seed-faster
Improve arraySeed utility
This commit is contained in:
@@ -112,11 +112,9 @@ export function arrayRescale(input: number[], newMin: number, newMax: number): n
|
|||||||
* @returns {T[]} The array.
|
* @returns {T[]} The array.
|
||||||
*/
|
*/
|
||||||
export function arraySeed<T>(val: T, length: number): T[] {
|
export function arraySeed<T>(val: T, length: number): T[] {
|
||||||
const a: T[] = [];
|
// Size the array up front for performance, and use `fill` to let the browser
|
||||||
for (let i = 0; i < length; i++) {
|
// optimize the operation better than we can with a `for` loop, if it wants.
|
||||||
a.push(val);
|
return new Array<T>(length).fill(val);
|
||||||
}
|
|
||||||
return a;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user