• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mlange-42 / arche / 4903779843

06 May 2023 09:50PM CUT coverage: 100.0%. Remained the same
4903779843

push

github

GitHub
Optimize archetype iteration (#272)

38 of 38 new or added lines in 3 files covered. (100.0%)

3719 of 3719 relevant lines covered (100.0%)

85808.07 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/ecs/bitset.go
1
package ecs
2

3
// Data structure for compact storage of booleans.
4
type bitSet struct {
5
        data []uint64
6
}
7

8
// Get a value.
9
func (b *bitSet) Get(bit eid) bool {
2,525,493✔
10
        chunk, bit := bit/wordSize, bit%wordSize
2,525,493✔
11
        mask := uint64(1 << bit)
2,525,493✔
12
        return b.data[chunk]&mask == mask
2,525,493✔
13
}
2,525,493✔
14

15
// Set a value.
16
func (b *bitSet) Set(bit eid, value bool) {
2,836,471✔
17
        chunk, bit := bit/wordSize, bit%wordSize
2,836,471✔
18
        if value {
2,866,531✔
19
                b.data[chunk] |= uint64(1 << bit)
30,060✔
20
        } else {
2,836,471✔
21
                b.data[chunk] &= uint64(^(1 << bit))
2,806,411✔
22
        }
2,806,411✔
23
}
24

25
// Reset all values.
26
func (b *bitSet) Reset() {
31✔
27
        ln := len(b.data)
31✔
28
        for i := 0; i < ln; i++ {
3,888✔
29
                b.data[i] = 0
3,857✔
30
        }
3,857✔
31
}
32

33
// Extend to hold at least the given bits.
34
func (b *bitSet) ExtendTo(length int) {
32,723✔
35
        chunks, bit := length/wordSize, length%wordSize
32,723✔
36
        if bit > 0 {
37,816✔
37
                chunks++
5,093✔
38
        }
5,093✔
39
        if len(b.data) >= chunks {
65,191✔
40
                return
32,468✔
41
        }
32,468✔
42

43
        old := b.data
255✔
44
        b.data = make([]uint64, chunks)
255✔
45

255✔
46
        copy(b.data, old)
255✔
47
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc