Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: quay/claircore
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 10b07ff07b91aa1f924e1b60b087a523aed09d48
Choose a base ref
..
head repository: quay/claircore
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e59f165e1c7fb159b33cc36ea0c8e7789f7d633c
Choose a head ref
Showing with 1 addition and 27 deletions.
  1. +1 −10 pkg/ctxlock/keyify.go
  2. +0 −17 pkg/ctxlock/keyify_safe.go
11 changes: 1 addition & 10 deletions pkg/ctxlock/keyify.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
//go:build !safe

package ctxlock

import (
"hash/fnv"
"reflect"
"unsafe"
)

// Keyify returns an int64 serialized into a []byte.
func keyify(key string) []byte {
const maxsize = 0x7fff0000
l := len(key)
h := fnv.New64a()
// This is (obviously) unsafe -- it provides mutable access to "key".
// However, it doesn't outlive this Write call, and the implementation
// can be read to ensure it doesn't modify it.
h.Write((*[maxsize]byte)(unsafe.Pointer((*reflect.StringHeader)(unsafe.Pointer(&key)).Data))[:l:l])
h.Write([]byte(key))
b := make([]byte, 0, 8)
return h.Sum(b)
}
17 changes: 0 additions & 17 deletions pkg/ctxlock/keyify_safe.go

This file was deleted.