We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fe73385 commit 35f149bCopy full SHA for 35f149b
1 file changed
ctxext/storage.go
@@ -41,7 +41,7 @@ func (s Storage) SaveTo(ctx *zero.Ctx, gid int64) error {
41
// Get bmp is a continuous 1's sequence like 0x00ff00
42
func (s Storage) Get(bmp int64) int64 {
43
sft := bits.TrailingZeros64(uint64(bmp))
44
- return (int64(s) & bmp) >> int64(sft)
+ return (int64(s) >> int64(sft)) & (bmp >> int64(sft))
45
}
46
47
// Set bmp is a continuous 1's sequence like 0x00ff00
@@ -50,7 +50,7 @@ func (s Storage) Set(x int64, bmp int64) Storage {
50
panic("cannot use bmp == 0")
51
52
53
- return Storage((int64(s) & (^bmp)) | ((x & (bmp >> int64(sft))) << int64(sft)))
+ return Storage((int64(s) & (^bmp)) | ((x << int64(sft)) & bmp))
54
55
56
// GetBool bmp must be 1-bit-long
0 commit comments