Skip to content

Commit

Permalink
made the selection process slightly more efficient
Browse files Browse the repository at this point in the history
thank you Simon from nois for your suggestion!!
  • Loading branch information
CluEleSsUK committed Nov 8, 2023
1 parent f620aaf commit 1ebe798
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ export function select(count: number, values: Array<string>, randomness: Uint8Ar
const chosenIndex = indexFromRandomness(currentRandomness, remainingValues.length)

// remove the chosen value from the remaining values and add it to the chosen values
chosenValues = [...chosenValues, remainingValues[chosenIndex]]
remainingValues = [
...remainingValues.slice(0, chosenIndex),
...remainingValues.slice(chosenIndex + 1, remainingValues.length)
]
chosenValues.push(...remainingValues.splice(chosenIndex, 1))
remainingDraws--
}

Expand Down

0 comments on commit 1ebe798

Please sign in to comment.