<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/subex/arithmetic.go
diff options
context:
space:
mode:
authorCharlie Stanton <charlie@shtanton.xyz>2023-04-21 12:51:25 +0100
committerCharlie Stanton <charlie@shtanton.xyz>2023-04-21 12:51:25 +0100
commit26bce7119200f37f8b9f3ddc1a2c76c85f7c88be (patch)
tree21a2aa762215e2230ba676454828c1497a568cc6 /subex/arithmetic.go
parent184118c1522ee4e78a0588fcac8eb235f512b599 (diff)
downloadstred-go-26bce7119200f37f8b9f3ddc1a2c76c85f7c88be.tar
Changes the implementation of Atomise and Compound to no longer use goroutines
This results in a massive performance boost, ~4x speedup
Diffstat (limited to 'subex/arithmetic.go')
-rw-r--r--subex/arithmetic.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/subex/arithmetic.go b/subex/arithmetic.go
index 52f576d..a7dc73a 100644
--- a/subex/arithmetic.go
+++ b/subex/arithmetic.go
@@ -10,7 +10,7 @@ func sumValues(atoms []walk.Atom) ([]walk.Atom, error) {
allBools := true
var sum float64 = 0
var any bool = false
- values, err := walk.MemoryCompound(atoms)
+ values, err := walk.Compound(atoms)
if err != nil {
return nil, err
}
@@ -50,7 +50,7 @@ func multiplyValues(atoms []walk.Atom) ([]walk.Atom, error) {
allBools := true
var product float64 = 1
var all bool = false
- values, err := walk.MemoryCompound(atoms)
+ values, err := walk.Compound(atoms)
if err != nil {
return nil, err
}
@@ -89,7 +89,7 @@ func multiplyValues(atoms []walk.Atom) ([]walk.Atom, error) {
// Does tries to cast all to numbers and negates them
func negateValues(atoms []walk.Atom) ([]walk.Atom, error) {
var negatedNumbers []walk.Atom
- values, err := walk.MemoryCompound(atoms)
+ values, err := walk.Compound(atoms)
if err != nil {
return nil, err
}
@@ -123,7 +123,7 @@ func negateValues(atoms []walk.Atom) ([]walk.Atom, error) {
// Else errors
func reciprocalValues(atoms []walk.Atom) ([]walk.Atom, error) {
var reciprocals []walk.Atom
- values, err := walk.MemoryCompound(atoms)
+ values, err := walk.Compound(atoms)
if err != nil {
return nil, err
}
@@ -156,7 +156,7 @@ func reciprocalValues(atoms []walk.Atom) ([]walk.Atom, error) {
// If all are castable to booleans, NOTs all and returns them
// Else errors
func notValues(atoms []walk.Atom) (notted []walk.Atom, err error) {
- values, err := walk.MemoryCompound(atoms)
+ values, err := walk.Compound(atoms)
if err != nil {
return nil, err
}