From 92aa56ba2050188f2bf459521906c76111c8e38c Mon Sep 17 00:00:00 2001 From: Jonas Wagner Date: Sun, 15 May 2022 07:06:35 +0200 Subject: [PATCH] Swap values with structured assignment rather than temporary (#210) Saves two lines and a variable. Also, a desperate attempt to save my Mana in https://manifold.markets/ManifoldMarkets/if-we-open-source-our-frontend-code --- common/util/random.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/common/util/random.ts b/common/util/random.ts index 740379e5..f52294f1 100644 --- a/common/util/random.ts +++ b/common/util/random.ts @@ -42,8 +42,6 @@ export function createRNG(seed: string) { export const shuffle = (array: any[], rand: () => number) => { for (let i = 0; i < array.length; i++) { const swapIndex = Math.floor(rand() * (array.length - i)) - const temp = array[i] - array[i] = array[swapIndex] - array[swapIndex] = temp + ;[array[i], array[swapIndex]] = [array[swapIndex], array[i]] } }