github.com/oarkflow/sio@v0.0.6/internal/maps/bits_amd64.go (about)

     1  //go:build amd64 && !nosimd
     2  
     3  package maps
     4  
     5  import (
     6  	"math/bits"
     7  	_ "unsafe"
     8  
     9  	"github.com/oarkflow/sio/internal/maps/simd"
    10  )
    11  
    12  const (
    13  	groupSize       = 16
    14  	maxAvgGroupLoad = 14
    15  )
    16  
    17  type bitset uint16
    18  
    19  func metaMatchH2(m *metadata, h h2) bitset {
    20  	b := simd.MatchMetadata((*[16]int8)(m), int8(h))
    21  	return bitset(b)
    22  }
    23  
    24  func metaMatchEmpty(m *metadata) bitset {
    25  	b := simd.MatchMetadata((*[16]int8)(m), empty)
    26  	return bitset(b)
    27  }
    28  
    29  func nextMatch(b *bitset) (s uint32) {
    30  	s = uint32(bits.TrailingZeros16(uint16(*b)))
    31  	*b &= ^(1 << s) // clear bit |s|
    32  	return
    33  }
    34  
    35  //go:linkname fastrand runtime.fastrand
    36  func fastrand() uint32