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

mlange-42 / ark-serde / 14019558887

23 Mar 2025 01:38PM CUT coverage: 96.023%. Remained the same
14019558887

push

github

web-flow
Profiling and optimizations (#13)

* use slice for component infos
* add profiling projects
* update changelog

3 of 3 new or added lines in 1 file covered. (100.0%)

338 of 352 relevant lines covered (96.02%)

42.14 hits per line

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

100.0
/types.go
1
package arkserde
2

3
import "github.com/mlange-42/ark/ecs"
4

5
const targetTag = ".ark.relation.Target"
6

7
type deserializer struct {
8
        World      ecs.EntityDump
9
        Types      []string
10
        Components []entry
11
        Resources  map[string]entry
12
}
13

14
type entry struct {
15
        Bytes []byte
16
}
17

18
func (e *entry) UnmarshalJSON(jsonData []byte) error {
259✔
19
        e.Bytes = jsonData
259✔
20
        return nil
259✔
21
}
259✔
22

23
type component struct {
24
        ID     ecs.ID
25
        Comp   interface{}
26
        Target ecs.Entity
27
}
28

29
// bitMask is a 256 bit bit-mask.
30
// It is also a [Filter] for including certain components.
31
type bitMask struct {
32
        bits [4]uint64 // 4x 64 bits of the mask
33
}
34

35
// Get reports whether the bit at the given index [ID] is set.
36
func (b *bitMask) Get(bit ecs.ID) bool {
242✔
37
        id := bit.Index()
242✔
38
        idx := id / 64
242✔
39
        offset := id - (64 * idx)
242✔
40
        mask := uint64(1 << offset)
242✔
41
        return b.bits[idx]&mask == mask
242✔
42
}
242✔
43

44
// Set sets the state of the bit at the given index.
45
func (b *bitMask) Set(bit ecs.ID, value bool) {
5✔
46
        id := bit.Index()
5✔
47
        idx := id / 64
5✔
48
        offset := id - (64 * idx)
5✔
49
        if value {
9✔
50
                b.bits[idx] |= (1 << offset)
4✔
51
        } else {
5✔
52
                b.bits[idx] &= ^(1 << offset)
1✔
53
        }
1✔
54
}
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