MCPcopy Create free account
hub / github.com/Monibuca/engine / FlushBits

Method FlushBits

util/bits/bits.go:101–118  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

99}
100
101func (self *Writer) FlushBits() (err error) {
102 if self.n > 0 {
103 var b [8]byte
104 bits := self.bits
105 if self.n%8 != 0 {
106 bits <<= uint(8 - (self.n % 8))
107 }
108 want := (self.n + 7) / 8
109 for i := 0; i < want; i++ {
110 b[i] = byte(bits >> uint((want-i-1)*8))
111 }
112 if _, err = self.W.Write(b[:want]); err != nil {
113 return
114 }
115 self.n = 0
116 }
117 return
118}

Callers 2

WriteBits64Method · 0.95
TestBitsFunction · 0.95

Calls 1

WriteMethod · 0.65

Tested by 1

TestBitsFunction · 0.76