feat: improve pick

This commit is contained in:
kwaroran
2024-06-14 08:27:32 +09:00
parent 4e4f6c4295
commit 27ad0810c4

View File

@@ -1126,7 +1126,7 @@ const matcher = (p1:string,matcherArg:matcherArg) => {
} }
function pickHashRand(cid:number,word:string) { function pickHashRand(cid:number,word:string) {
let hashAddress = cid * 23515 let hashAddress = 5515
const rand = (word:string) => { const rand = (word:string) => {
for (let counter = 0; counter<word.length; counter++){ for (let counter = 0; counter<word.length; counter++){
hashAddress = ((hashAddress << 5) + hashAddress) + word.charCodeAt(counter) hashAddress = ((hashAddress << 5) + hashAddress) + word.charCodeAt(counter)
@@ -1134,6 +1134,10 @@ function pickHashRand(cid:number,word:string) {
return hashAddress return hashAddress
} }
const randF = sfc32(rand(word), rand(word), rand(word), rand(word)) const randF = sfc32(rand(word), rand(word), rand(word), rand(word))
const v = cid % 1000
for (let i = 0; i < v; i++){
randF()
}
return randF() return randF()
} }