소스 검색

changed []byte to string after finding out string indexing is faster than []byte in Go, since we're never modifying our string and only working with the accumulator we should see an improvement in speed in general

master
William Dillon 3 년 전
부모
커밋
cb20cac2f1
1개의 변경된 파일3개의 추가작업 그리고 3개의 파일을 삭제
  1. 3
    3
      mishmash.go

+ 3
- 3
mishmash.go 파일 보기

return primes[n&0xff] return primes[n&0xff]
} }


func Engine(buffer []byte, length int, accumulator uint64) uint64 {
func Engine(buffer string, length int, accumulator uint64) uint64 {
for i := 0; i < length; i++ { for i := 0; i < length; i++ {
b := buffer[i] b := buffer[i]
accumulator += uint64(slct(accumulator)) + uint64(b) accumulator += uint64(slct(accumulator)) + uint64(b)
return accumulator return accumulator
} }


func Mishmash(buffer []byte, nums ...uint64) uint32 {
func Mishmash(buffer string, nums ...uint64) uint32 {
// nums is a seed/accumulator // nums is a seed/accumulator
var accumulator uint64 var accumulator uint64
if 0 == len(nums) { if 0 == len(nums) {
// example below used to validate output against C++ mishmash // example below used to validate output against C++ mishmash
/* /*
func main() { func main() {
buf := []byte("Hello world!")
buf := "Hello world!"
first := MishmashAccumulator(Engine(buf, len(buf), 0)) first := MishmashAccumulator(Engine(buf, len(buf), 0))
second := MishmashAccumulator(Engine(buf, len(buf), 1)) second := MishmashAccumulator(Engine(buf, len(buf), 1))
var combo uint64 var combo uint64

Loading…
취소
저장