mirror of
https://github.com/vsariola/sointu.git
synced 2025-05-28 03:10:24 -04:00
perf: do not use TotalVoices as it causes heap allocations
This commit is contained in:
parent
b73fc0b95b
commit
943073d0cc
6
patch.go
6
patch.go
@ -422,7 +422,11 @@ func (p Patch) FirstVoiceForInstrument(instrIndex int) int {
|
||||
return 0
|
||||
}
|
||||
instrIndex = min(instrIndex, len(p))
|
||||
return TotalVoices(p[:instrIndex])
|
||||
ret := 0
|
||||
for i := 0; i < instrIndex; i++ {
|
||||
ret += p[i].NumVoices
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
// InstrumentForVoice returns the instrument number for the given voice index.
|
||||
|
6
song.go
6
song.go
@ -275,7 +275,11 @@ func (l Score) FirstVoiceForTrack(track int) int {
|
||||
return 0
|
||||
}
|
||||
track = min(track, len(l.Tracks))
|
||||
return TotalVoices(l.Tracks[:track])
|
||||
ret := 0
|
||||
for i := 0; i < track; i++ {
|
||||
ret += l.Tracks[i].NumVoices
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
// LengthInRows returns just RowsPerPattern * Length, as the length is the
|
||||
|
Loading…
Reference in New Issue
Block a user