From 27d769cd073ab4a77d7ba1cd6c76d52cd51d790f Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sun, 11 Aug 2024 15:49:35 +0200 Subject: [PATCH] Do not copy on keyframes.Slice if not needed --- transcoder/src/keyframes.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/transcoder/src/keyframes.go b/transcoder/src/keyframes.go index f8d74378..2b3ade5a 100644 --- a/transcoder/src/keyframes.go +++ b/transcoder/src/keyframes.go @@ -37,7 +37,12 @@ func (kf *Keyframe) Slice(start int32, end int32) []float64 { } kf.info.mutex.RLock() defer kf.info.mutex.RUnlock() + ref := kf.Keyframes[start:end] + if kf.IsDone { + return ref + } + // make a copy since we will continue to mutate the array. ret := make([]float64, end-start) copy(ret, ref) return ret