MCPcopy Create free account
hub / github.com/AdRoll/baker / findFirstZero64

Function findFirstZero64

pkg/buffercache/bitmap.go:27–37  ·  view source on GitHub ↗

findFirstZero64 returns the index of the first bit at 0, starting from the LSB (least significant bit).

(x uint64)

Source from the content-addressed store, hash-verified

25// findFirstZero64 returns the index of the first bit at 0, starting from the
26// LSB (least significant bit).
27func findFirstZero64(x uint64) (int, bool) {
28 l := bits.LeadingZeros64(x)
29 if l != 0 {
30 return 63, true
31 }
32 l = bits.LeadingZeros64(^x)
33 if l == 64 {
34 return 0, false
35 }
36 return int(63 - l), true
37}
38
39// setBit sets bit i (0-based, starting from LSB)
40func (bm *bitmap) setBit(i int) {

Callers 2

Test_findFirstZero64Function · 0.85
findFreeCellMethod · 0.85

Calls

no outgoing calls

Tested by 1

Test_findFirstZero64Function · 0.68