CheckAllValid checks whether all bits are 1 in a bool typed vector.
()
| 281 | |
| 282 | // CheckAllValid checks whether all bits are 1 in a bool typed vector. |
| 283 | func (v *Vector) CheckAllValid() bool { |
| 284 | i := 0 |
| 285 | totalCompleteBytes := v.Size / 8 |
| 286 | remainingBits := v.Size % 8 |
| 287 | wordBoundary := totalCompleteBytes - totalCompleteBytes%4 |
| 288 | |
| 289 | // First check word by word. |
| 290 | for ; i < wordBoundary; i += 4 { |
| 291 | if !(*(*uint32)(utils.MemAccess(unsafe.Pointer(v.buffer), i)) == 0xFFFFFFFF) { |
| 292 | return false |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | // then we check byte by byte. |
| 297 | for ; i < totalCompleteBytes; i++ { |
| 298 | if !(*(*uint8)(utils.MemAccess(unsafe.Pointer(v.buffer), i)) == 0xFF) { |
| 299 | return false |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | if remainingBits == 0 { |
| 304 | return true |
| 305 | } |
| 306 | |
| 307 | // check remaining bits. |
| 308 | var mask uint8 = (1 << uint(remainingBits)) - 1 |
| 309 | return ((*(*uint8)(utils.MemAccess(unsafe.Pointer(v.buffer), i))) & mask) == mask |
| 310 | } |
no test coverage detected