Inlining checks+update readme

This commit is contained in:
bloeys
2022-05-22 20:24:07 +04:00
parent e45e4d3304
commit 547d3ad234
2 changed files with 13 additions and 2 deletions

View File

@ -22,7 +22,6 @@ gglm currently has the following:
## Usage
```go
import "github.com/bloeys/gglm/gglm"
@ -43,10 +42,15 @@ func main() {
println(v1.Eq(v2))
v2.Set(1, 2)
println(v1.Eq(v2))
//This performs: v1 += v2
//v1 is returned from the function, so we can chain calls that operate on v1
newX := v1.Add(v2).X()
println("newX:", newX)
}
```
## Notes
You can check compiler inlining decisions using `go run -gcflags "-m" .`. Some functions look a bit weird compared to similar ones
because we are trying to reduce function complexity so the compiler inlines.

View File

@ -64,6 +64,9 @@ func main() {
v2.Set(1, 2)
println(v1.Eq(v2))
v1.AddXY(v2.X(), v2.Y())
println(v1.String())
println("V1: " + v1.String())
v1.Normalize()
println("V1 Normal: " + v1.String())
@ -97,6 +100,10 @@ func main() {
println(gglm.DotVec4(v5, v6))
v5.Add(v6)
v5.AddXYZW(v6.X(), v6.Y(), v6.Z(), v6.W())
println(v6.String())
println("V6: " + v6.String())
v6.Normalize()
println("V6 Normal: " + v6.String())