| 1 | package instrumentationscip-go gomod github.com/antithesishq/antithesis-sdk-go . `github.com/antithesishq/antithesis-sdk-go/instrumentation`/ |
| 2 | |
| 3 | import ( |
| 4 | "syncscip-go gomod github.com/golang/go/src go1.24.0 sync/" |
| 5 | ) |
| 6 | |
| 7 | // bitSet is a rudimentary implementation suitable for |
| 8 | // the Antithesis Go instrumentation wrappers. One |
| 9 | // can set bits; one cannot unset them. It is 0-indexed, |
| 10 | // although our edges begin at 1. The value type is |
| 11 | // int, to be consistent with our "edge" type. Negative |
| 12 | // index values will result in a panic. |
| 13 | type bitSetscip-go gomod github.com/antithesishq/antithesis-sdk-go . `github.com/antithesishq/antithesis-sdk-go/instrumentation`/bitSet# struct { |
| 14 | // There seems to be no performance differences |
| 15 | // among the different integer types. |
| 16 | slotsscip-go gomod github.com/antithesishq/antithesis-sdk-go . `github.com/antithesishq/antithesis-sdk-go/instrumentation`/bitSet#slots. []uint64 |
| 17 | mutexscip-go gomod github.com/antithesishq/antithesis-sdk-go . `github.com/antithesishq/antithesis-sdk-go/instrumentation`/bitSet#mutex. syncscip-go gomod github.com/golang/go/src go1.24.0 sync/.RWMutexscip-go gomod github.com/golang/go/src go1.24.0 sync/RWMutex# |
| 18 | } |
| 19 | |
| 20 | func (b *bitSetscip-go gomod github.com/antithesishq/antithesis-sdk-go . `github.com/antithesishq/antithesis-sdk-go/instrumentation`/bitSet#) slotAndBitscip-go gomod github.com/antithesishq/antithesis-sdk-go . `github.com/antithesishq/antithesis-sdk-go/instrumentation`/bitSet#slotAndBit().(index int) (int, int) { |
| 21 | // One assumes that the compiler will optimize these. |
| 22 | return index / 64, index % 64 |
| 23 | } |
| 24 | |
| 25 | func (b *bitSetscip-go gomod github.com/antithesishq/antithesis-sdk-go . `github.com/antithesishq/antithesis-sdk-go/instrumentation`/bitSet#) getscip-go gomod github.com/antithesishq/antithesis-sdk-go . `github.com/antithesishq/antithesis-sdk-go/instrumentation`/bitSet#get().(slot, bit int) bool { |
| 26 | if slot >= len(b.slotsscip-go gomod github.com/antithesishq/antithesis-sdk-go . `github.com/antithesishq/antithesis-sdk-go/instrumentation`/bitSet#slots.) { |
| 27 | return false |
| 28 | } |
| 29 | mask := (uint64(1) << bit) |
| 30 | return (b.slotsscip-go gomod github.com/antithesishq/antithesis-sdk-go . `github.com/antithesishq/antithesis-sdk-go/instrumentation`/bitSet#slots.[slot] & mask) != 0 |
| 31 | } |
| 32 | |
| 33 | // Get returns the value at this index. |
| 34 | func (b *bitSetscip-go gomod github.com/antithesishq/antithesis-sdk-go . `github.com/antithesishq/antithesis-sdk-go/instrumentation`/bitSet#) Getscip-go gomod github.com/antithesishq/antithesis-sdk-go . `github.com/antithesishq/antithesis-sdk-go/instrumentation`/bitSet#Get().(index int) bool { |
| 35 | slot, bit := b.slotAndBitscip-go gomod github.com/antithesishq/antithesis-sdk-go . `github.com/antithesishq/antithesis-sdk-go/instrumentation`/bitSet#slotAndBit().(index) |
| 36 | b.mutexscip-go gomod github.com/antithesishq/antithesis-sdk-go . `github.com/antithesishq/antithesis-sdk-go/instrumentation`/bitSet#mutex..RLockscip-go gomod github.com/golang/go/src go1.24.0 sync/RWMutex#RLock().() |
| 37 | defer b.mutexscip-go gomod github.com/antithesishq/antithesis-sdk-go . `github.com/antithesishq/antithesis-sdk-go/instrumentation`/bitSet#mutex..RUnlockscip-go gomod github.com/golang/go/src go1.24.0 sync/RWMutex#RUnlock().() |
| 38 | return b.getscip-go gomod github.com/antithesishq/antithesis-sdk-go . `github.com/antithesishq/antithesis-sdk-go/instrumentation`/bitSet#get().(slot, bit) |
| 39 | } |
| 40 | |
| 41 | // Set will only switch a bit on. |
| 42 | func (b *bitSetscip-go gomod github.com/antithesishq/antithesis-sdk-go . `github.com/antithesishq/antithesis-sdk-go/instrumentation`/bitSet#) Setscip-go gomod github.com/antithesishq/antithesis-sdk-go . `github.com/antithesishq/antithesis-sdk-go/instrumentation`/bitSet#Set().(index int) { |
| 43 | slot, bit := b.slotAndBitscip-go gomod github.com/antithesishq/antithesis-sdk-go . `github.com/antithesishq/antithesis-sdk-go/instrumentation`/bitSet#slotAndBit().(index) |
| 44 | b.mutexscip-go gomod github.com/antithesishq/antithesis-sdk-go . `github.com/antithesishq/antithesis-sdk-go/instrumentation`/bitSet#mutex..Lockscip-go gomod github.com/golang/go/src go1.24.0 sync/RWMutex#Lock().() |
| 45 | defer b.mutexscip-go gomod github.com/antithesishq/antithesis-sdk-go . `github.com/antithesishq/antithesis-sdk-go/instrumentation`/bitSet#mutex..Unlockscip-go gomod github.com/golang/go/src go1.24.0 sync/RWMutex#Unlock().() |
| 46 | if slot >= len(b.slotsscip-go gomod github.com/antithesishq/antithesis-sdk-go . `github.com/antithesishq/antithesis-sdk-go/instrumentation`/bitSet#slots.) { |
| 47 | // Go takes care of the *capacity* under the covers. |
| 48 | // So we don't need a tricky implementation, or |
| 49 | // a fixed size. Expansion is cheap. |
| 50 | extension := 1 + int(slot) - len(b.slotsscip-go gomod github.com/antithesishq/antithesis-sdk-go . `github.com/antithesishq/antithesis-sdk-go/instrumentation`/bitSet#slots.) |
| 51 | b.slotsscip-go gomod github.com/antithesishq/antithesis-sdk-go . `github.com/antithesishq/antithesis-sdk-go/instrumentation`/bitSet#slots. = append(b.slotsscip-go gomod github.com/antithesishq/antithesis-sdk-go . `github.com/antithesishq/antithesis-sdk-go/instrumentation`/bitSet#slots., make([]uint64, extension)...) |
| 52 | } |
| 53 | mask := (uint64(1) << bit) |
| 54 | b.slotsscip-go gomod github.com/antithesishq/antithesis-sdk-go . `github.com/antithesishq/antithesis-sdk-go/instrumentation`/bitSet#slots.[slot] |= mask |
| 55 | } |