100-go-mistakes/src/12-optimizations/91-cpu-caches/slice-structs/main.go
Teiva Harsanyi b7a7eb62fe Merging desc
2023-09-12 00:44:52 +02:00

27 lines
340 B
Go

package main
type Foo struct {
a int64
b int64
}
func sumFoo(foos []Foo) int64 {
var total int64
for i := 0; i < len(foos); i++ {
total += foos[i].a
}
return total
}
type Bar struct {
a []int64
b []int64
}
func sumBar(bar Bar) int64 {
var total int64
for i := 0; i < len(bar.a); i++ {
total += bar.a[i]
}
return total
}