github.com/aristanetworks/goarista@v0.0.0-20240514173732-cca2755bbd44/key/hash_no119.go (about)

     1  // Copyright (c) 2022 Arista Networks, Inc.
     2  // Use of this source code is governed by the Apache License 2.0
     3  // that can be found in the COPYING file.
     4  
     5  //go:build !go1.19
     6  
     7  package key
     8  
     9  import (
    10  	"hash/maphash"
    11  )
    12  
    13  // hashBytes is a less efficient version of maphash.Bytes, which was introduced in go1.19
    14  func hashBytes(seed maphash.Seed, v []byte) uint64 {
    15  	var h maphash.Hash
    16  	h.SetSeed(seed)
    17  	h.Write(v)
    18  	return h.Sum64()
    19  }
    20  
    21  // hashString is a less efficient version of maphash.String, which was introduced in go1.19
    22  func hashString(seed maphash.Seed, v string) uint64 {
    23  	var h maphash.Hash
    24  	h.SetSeed(seed)
    25  	h.WriteString(v)
    26  	return h.Sum64()
    27  }