ソースを参照

updating mishmash - changed some types to remove a lot of casting from Engine(), renamed slct to selectPrime. removed some extra code from the Mishmash benchmark

master
William Dillon 3年前
コミット
5f5bdae562
2個のファイルの変更6行の追加7行の削除
  1. 5
    5
      mishmash.go
  2. 1
    2
      mishmash_test.go

+ 5
- 5
mishmash.go ファイルの表示

@@ -34,15 +34,15 @@ var PrimeSet = [256]uint32{
2625015193, 2795623993, 3911522341, 3507684083, 3553065317, 3987511039, 2786582429, 2534596151,
}

func slct(n uint64) uint32 {
return PrimeSet[n&0xff]
func selectPrime(n uint64) uint64 {
return uint64(PrimeSet[n&0xff])
}

func Engine(buffer string, length int, accumulator uint64) uint64 {
for i := 0; i < length; i++ {
b := buffer[i]
var accumulator1 uint64 = uint64(slct(accumulator) + uint32(b))
var accumulator2 uint64 = ^accumulator * uint64(slct(uint64(b)))
b := uint64(buffer[i])
var accumulator1 uint64 = selectPrime(accumulator) + b
var accumulator2 uint64 = ^accumulator * selectPrime(b)
var accumulator3 = accumulator >> (32 + ((b & 0x1F) ^ (b >> 5)))
accumulator = accumulator1 + accumulator2 + accumulator3
}

+ 1
- 2
mishmash_test.go ファイルの表示

@@ -46,7 +46,6 @@ func TestEngineAndAccumulator(t *testing.T) {
func BenchmarkHashGeneration(b *testing.B) {
test := "google.com"
for i := 0; i < b.N; i++ {
accum := uint64(Mishmash(test, 0))<<32 | uint64(Mishmash(test, 1))
fmt.Printf("%016x\n", accum)
Mishmash(test, 0)
}
}

読み込み中…
キャンセル
保存