Skip to content

Commit

Permalink
Merge pull request #13 from go-faster/feat/col-bool-speedup
Browse files Browse the repository at this point in the history
feat(col.bool): improve performance
  • Loading branch information
ernado authored Jan 2, 2022
2 parents 8706ec0 + 787892f commit dedf126
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions proto/col_bool_safe.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ import "github.com/go-faster/errors"
func (c ColBool) EncodeColumn(b *Buffer) {
start := len(b.Buf)
b.Buf = append(b.Buf, make([]byte, len(c))...)
for i := range c {
if c[i] {
b.Buf[i+start] = boolTrue
} else {
b.Buf[i+start] = boolFalse
}
dst := b.Buf[start:]
for i, v := range c {
dst[i] = boolToByte(v)
}
}

func boolToByte(b bool) byte {
if b {
return boolTrue
}
return boolFalse
}

// DecodeColumn decodes Bool rows from *Reader.
Expand Down

0 comments on commit dedf126

Please sign in to comment.