Skip to content

Commit

Permalink
optimize float series memory allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Jan 17, 2025
1 parent 7ce6f3e commit 5fd3a6a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/types/series_float64.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ type Float64Series struct {

func NewFloat64Series(v ...float64) *Float64Series {
s := &Float64Series{}
s.Slice = v

if len(v) == 0 {
s.Slice = make([]float64, 0, 1024)
} else {
s.Slice = v
}

s.SeriesBase.Series = &s.Slice
return s
}
Expand Down Expand Up @@ -60,7 +66,6 @@ func (f *Float64Series) AddSubscriber(fn func(v float64)) {
}
}


// Bind binds the source event to the target (Float64Calculator)
// A Float64Calculator should be able to calculate the float64 result from a single float64 argument input
func (f *Float64Series) Bind(source Float64Source, target Float64Calculator) {
Expand Down

0 comments on commit 5fd3a6a

Please sign in to comment.