optimizations
Some checks failed
Build / build (push) Successful in 10m29s
Publish Image / publish (push) Failing after 31s
Test / build (push) Failing after 6m34s

This commit is contained in:
Chuck Smith
2024-04-02 14:08:08 -04:00
parent 4c9ec5aaaa
commit 07fd82b261
23 changed files with 296 additions and 265 deletions

View File

@@ -63,11 +63,8 @@ func (ao *Array) String() string {
return ao.Inspect()
}
func (ao *Array) Less(i, j int) bool {
if cmp, ok := ao.Elements[i].(Comparable); ok {
return cmp.Compare(ao.Elements[j]) == -1
}
return false
func (a *Array) Less(i, j int) bool {
return a.Elements[i].Compare(a.Elements[j]) == -1
}
func (a *Array) Add(other Object) (Object, error) {
@@ -129,18 +126,15 @@ func (ao *Array) Set(index, other Object) error {
return nil
}
func (ao *Array) Compare(other Object) int {
func (a *Array) Compare(other Object) int {
if obj, ok := other.(*Array); ok {
if len(ao.Elements) != len(obj.Elements) {
if len(a.Elements) != len(obj.Elements) {
return -1
}
for i, el := range ao.Elements {
cmp, ok := el.(Comparable)
if !ok {
return -1
}
if cmp.Compare(obj.Elements[i]) != 0 {
return cmp.Compare(obj.Elements[i])
for i, el := range a.Elements {
val := el.Compare(obj.Elements[i])
if val != 0 {
return val
}
}