Skip to content

Commit 4d2b13f

Browse files
committed
Update
1 parent e20d664 commit 4d2b13f

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

.github/workflows/go.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ jobs:
1515
runs-on: ubuntu-latest
1616
steps:
1717

18+
- name: Check out code into the Go module directory
19+
uses: actions/checkout@v5
20+
1821
- name: Set up Go 1.x
19-
uses: actions/setup-go@v2
22+
uses: actions/setup-go@v6
2023
with:
2124
go-version: 1.x
2225
id: go
2326

24-
- name: Check out code into the Go module directory
25-
uses: actions/checkout@v2
26-
2727
- name: Build
2828
run: go build -v ./...
2929

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# variable-lenght bitfield
22

3-
[![GoDoc](https://godoc.org/github.com/dim13/bit?status.svg)](https://godoc.org/github.com/dim13/bit)
4-
[![Build](https://github.com/dim13/bit/workflows/build/badge.svg)](https://github.com/dim13/bit/actions)
3+
[![Go Reference](https://pkg.go.dev/badge/github.com/dim13/bit.svg)](https://pkg.go.dev/github.com/dim13/bit)
4+
[![Go](https://github.com/dim13/bit/actions/workflows/go.yml/badge.svg)](https://github.com/dim13/bit/actions/workflows/go.yml)

bit.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,12 @@ func (f *Field) IsClear(k int) bool {
3232
n, m := k>>3, byte(1<<uint(k&7))
3333
return len(*f) <= n || (*f)[n]&m == 0
3434
}
35+
36+
func (f *Field) Shrink() {
37+
for i := len(*f); i > 0; i-- {
38+
if (*f)[i-1] != 0 {
39+
break
40+
}
41+
*f = (*f)[:i-1]
42+
}
43+
}

bit_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,15 @@ func TestBit(t *testing.T) {
1818
}
1919
}
2020
}
21+
22+
func TestShrink(t *testing.T) {
23+
bf := new(Field)
24+
bf.Set(0)
25+
bf.Set(32)
26+
bf.Set(64)
27+
t.Log(bf)
28+
bf.Clear(64)
29+
bf.Shrink()
30+
bf.Set(128)
31+
t.Log(bf)
32+
}

0 commit comments

Comments
 (0)