Skip to content

Commit 6833d2f

Browse files
fix: #2956 (#2957)
Signed-off-by: monkey92t <[email protected]> Co-authored-by: Vladimir Mihailenco <[email protected]>
1 parent 683f4fa commit 6833d2f

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

bitmap_commands.go

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,19 @@ const BitCountIndexByte string = "BYTE"
4545
const BitCountIndexBit string = "BIT"
4646

4747
func (c cmdable) BitCount(ctx context.Context, key string, bitCount *BitCount) *IntCmd {
48-
args := []interface{}{"bitcount", key}
48+
args := make([]any, 2, 5)
49+
args[0] = "bitcount"
50+
args[1] = key
4951
if bitCount != nil {
50-
if bitCount.Unit == "" {
51-
bitCount.Unit = "BYTE"
52-
}
53-
if bitCount.Unit != BitCountIndexByte && bitCount.Unit != BitCountIndexBit {
54-
cmd := NewIntCmd(ctx)
55-
cmd.SetErr(errors.New("redis: invalid bitcount index"))
56-
return cmd
52+
args = append(args, bitCount.Start, bitCount.End)
53+
if bitCount.Unit != "" {
54+
if bitCount.Unit != BitCountIndexByte && bitCount.Unit != BitCountIndexBit {
55+
cmd := NewIntCmd(ctx)
56+
cmd.SetErr(errors.New("redis: invalid bitcount index"))
57+
return cmd
58+
}
59+
args = append(args, bitCount.Unit)
5760
}
58-
args = append(
59-
args,
60-
bitCount.Start,
61-
bitCount.End,
62-
string(bitCount.Unit),
63-
)
6461
}
6562
cmd := NewIntCmd(ctx, args...)
6663
_ = c(ctx, cmd)

0 commit comments

Comments
 (0)