From 5dbe882c778e710917296319205f7a195189b00a Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 3 May 2021 15:20:29 -0600 Subject: [PATCH] Don't recurse on arrayFastResample Fixes https://github.com/vector-im/element-web/issues/17136 --- src/utils/arrays.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/utils/arrays.ts b/src/utils/arrays.ts index f7e693452b..1e130bd605 100644 --- a/src/utils/arrays.ts +++ b/src/utils/arrays.ts @@ -36,14 +36,12 @@ export function arrayFastResample(input: number[], points: number): number[] { } } else { // Smaller inputs mean we have to spread the values over the desired length. We - // end up overshooting the target length in doing this, so we'll resample down - // before returning. This recursion is risky, but mathematically should not go - // further than 1 level deep. + // end up overshooting the target length in doing this, but we're not looking to + // be super accurate so we'll let the sanity trims do their job. const spreadFactor = Math.ceil(points / input.length); for (const val of input) { samples.push(...arraySeed(val, spreadFactor)); } - samples = arrayFastResample(samples, points); } // Sanity fill, just in case