Use builtin max instead of custom one

This commit is contained in:
Zoe Roux 2024-04-01 22:18:44 +02:00
parent 83110374f8
commit ea98598399
No known key found for this signature in database
2 changed files with 2 additions and 10 deletions

View File

@ -1,7 +1,6 @@
package src
import (
"cmp"
"encoding/json"
"fmt"
"io"
@ -168,13 +167,6 @@ func OrNull(str string) *string {
return &str
}
func Max[T cmp.Ordered](x, y T) T {
if x < y {
return y
}
return x
}
var SubtitleExtensions = map[string]string{
"subrip": "srt",
"ass": "ass",
@ -316,7 +308,7 @@ func getInfo(path string, route string) (*MediaInfo, error) {
Link: link,
}
}),
Chapters: Map(make([]Chapter, Max(chapters_end-chapters_begin, 1)-1), func(_ Chapter, i int) Chapter {
Chapters: Map(make([]Chapter, max(chapters_end-chapters_begin, 1)-1), func(_ Chapter, i int) Chapter {
return Chapter{
StartTime: ParseTime(mi.GetI(mediainfo.StreamMenu, 0, int(chapters_begin)+i, mediainfo.InfoName)),
// +1 is safe, the value at chapters_end contains the right duration

View File

@ -68,7 +68,7 @@ func NewStream(file *FileStream, handle StreamHandle, ret *Stream) {
ret.heads = make([]Head, 0)
length, is_done := file.Keyframes.Length()
ret.segments = make([]Segment, length, Max(length, 2000))
ret.segments = make([]Segment, length, max(length, 2000))
for seg := range ret.segments {
ret.segments[seg].channel = make(chan struct{})
}