MCPcopy Index your code
hub / github.com/Shopify/go-lua / maybeResizeArray

Method maybeResizeArray

tables.go:60–80  ·  view source on GitHub ↗
(key int)

Source from the content-addressed store, hash-verified

58}
59
60func (t *table) maybeResizeArray(key int) bool {
61 // Precondition: key > len(t.array).
62 occupancy := 0
63 for _, v := range t.array {
64 if v != nil {
65 occupancy++
66 }
67 }
68 for k, v := range t.hash {
69 if f, ok := k.(float64); ok && v != nil {
70 if i := int(f); i <= key && float64(i) == f {
71 occupancy++
72 }
73 }
74 }
75 if occupancy >= key>>1 {
76 t.extendArray(max(occupancy*2, key)) // TODO Tune growth function.
77 return true
78 }
79 return false
80}
81
82func (t *table) addOrInsertHash(k, v value) {
83 if _, ok := t.hash[k]; !ok {

Callers 1

putAtIntMethod · 0.95

Calls 2

extendArrayMethod · 0.95
maxFunction · 0.85

Tested by

no test coverage detected