Fix VM memory allocation optimizations by reducing what we allocate on the heap
Some checks failed
Build / build (push) Successful in 10m25s
Publish Image / publish (push) Failing after 39s
Test / build (push) Successful in 11m19s

This commit is contained in:
Charles Smith
2024-03-31 20:44:50 -04:00
parent a85dc73954
commit aebbe43999
61 changed files with 383 additions and 370 deletions

View File

@@ -25,7 +25,7 @@ func (ao *Array) PopLeft() Object {
ao.Elements = ao.Elements[1:]
return e
}
return &Null{}
return Null{}
}
func (ao *Array) PopRight() Object {
@@ -34,7 +34,7 @@ func (ao *Array) PopRight() Object {
ao.Elements = ao.Elements[:(len(ao.Elements) - 1)]
return e
}
return &Null{}
return Null{}
}
func (ao *Array) Prepend(obj Object) {
@@ -89,7 +89,7 @@ func (ao *Array) Mul(other Object) (Object, error) {
}
var elements []Object
N := int(other.(*Integer).Value)
N := int(other.(Integer).Value)
for i := 0; i < N; i++ {
elements = append(elements, ao.Elements...)
}
@@ -102,10 +102,10 @@ func (ao *Array) Get(index Object) (Object, error) {
return nil, fmt.Errorf("invalid type for array index, expected Integer got %s", index.Type())
}
i := index.(*Integer).Value
i := index.(Integer).Value
N := int64(len(ao.Elements))
if i < 0 || i >= N {
return &Null{}, nil
return Null{}, nil
}
return ao.Elements[i], nil
@@ -116,7 +116,7 @@ func (ao *Array) Set(index, other Object) error {
return fmt.Errorf("invalid type for array index, expected Integer got %s", index.Type())
}
i := index.(*Integer).Value
i := index.(Integer).Value
N := int64(len(ao.Elements))
if i < 0 || i >= N {
return fmt.Errorf("index out of bounds %d with array length %d", i, N)