mirror of
https://github.com/element-hq/element-web
synced 2024-10-24 11:45:50 +03:00
Merge pull request #5957 from matrix-org/travis/voicemessages/resample
Don't recurse on arrayFastResample
This commit is contained in:
commit
9b7665433f
1 changed files with 2 additions and 4 deletions
|
@ -36,14 +36,12 @@ export function arrayFastResample(input: number[], points: number): number[] {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Smaller inputs mean we have to spread the values over the desired length. We
|
// 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
|
// end up overshooting the target length in doing this, but we're not looking to
|
||||||
// before returning. This recursion is risky, but mathematically should not go
|
// be super accurate so we'll let the sanity trims do their job.
|
||||||
// further than 1 level deep.
|
|
||||||
const spreadFactor = Math.ceil(points / input.length);
|
const spreadFactor = Math.ceil(points / input.length);
|
||||||
for (const val of input) {
|
for (const val of input) {
|
||||||
samples.push(...arraySeed(val, spreadFactor));
|
samples.push(...arraySeed(val, spreadFactor));
|
||||||
}
|
}
|
||||||
samples = arrayFastResample(samples, points);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sanity fill, just in case
|
// Sanity fill, just in case
|
||||||
|
|
Loading…
Reference in a new issue