Skip to content

Commit

Permalink
Merge pull request #1 from smira/noescape
Browse files Browse the repository at this point in the history
Add Go compiler directive 'noescape' to assembly implementations
  • Loading branch information
Travis Bischel authored Feb 11, 2019
2 parents 7f484ce + 2e42a5a commit f46bb17
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions murmur128_decl.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,30 @@

package murmur3

//go:noescape

// Sum128 returns the murmur3 sum of data. It is equivalent to the following
// sequence (without the extra burden and the extra allocation):
// hasher := New128()
// hasher.Write(data)
// return hasher.Sum128()
func Sum128(data []byte) (h1 uint64, h2 uint64)

//go:noescape

// SeedSum128 returns the murmur3 sum of data with digests initialized to seed1
// and seed2.
//
// The canonical implementation allows only one uint32 seed; to imitate that
// behavior, use the same, uint32-max seed for seed1 and seed2.
func SeedSum128(seed1, seed2 uint64, data []byte) (h1 uint64, h2 uint64)

//go:noescape

// StringSum128 is the string version of Sum128.
func StringSum128(data string) (h1 uint64, h2 uint64)

//go:noescape

// SeedStringSum128 is the string version of SeedSum128.
func SeedStringSum128(seed1, seed2 uint64, data string) (h1 uint64, h2 uint64)
8 changes: 8 additions & 0 deletions murmur32_decl.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,27 @@

package murmur3

//go:noescape

// Sum32 returns the murmur3 sum of data. It is equivalent to the following
// sequence (without the extra burden and the extra allocation):
// hasher := New32()
// hasher.Write(data)
// return hasher.Sum32()
func Sum32(data []byte) (h1 uint32)

//go:noescape

// SeedSum32 returns the murmur3 sum of data with the digest initialized to
// seed.
func SeedSum32(seed uint32, data []byte) (h1 uint32)

//go:noescape

// StringSum32 is the string version of Sum32.
func StringSum32(data string) (h1 uint32)

//go:noescape

// SeedStringSum32 is the string version of SeedSum32.
func SeedStringSum32(seed uint32, data string) (h1 uint32)

0 comments on commit f46bb17

Please sign in to comment.