Skip to content

Commit

Permalink
only add padding if length isn't divisble by 8
Browse files Browse the repository at this point in the history
  • Loading branch information
cfi2017 committed Apr 20, 2020
1 parent e3ce872 commit 5e5e94a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions internal/item/bits.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ func (w *Writer) WriteInt(v uint64, n int) error {
func (w *Writer) GetBytes() []byte {
bs := make([]byte, 0)
padding := 8 - len(*w)%8
for i := 0; i < padding; i++ {
*w = "0" + *w
if padding != 8 {
for i := 0; i < padding; i++ {
*w = "0" + *w
}
}
for i := len(*w)/8 - 1; i > -1; i-- {
i, err := strconv.ParseUint(string((*w)[i*8:i*8+8]), 2, 8)
Expand Down

0 comments on commit 5e5e94a

Please sign in to comment.