Skip to content

Commit

Permalink
use map[]struct{} instead of map[]bool for altsWritten as set impleme…
Browse files Browse the repository at this point in the history
…ntation;
  • Loading branch information
vany-egorov committed Nov 25, 2020
1 parent 180dc61 commit db489ea
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,17 @@ func (p *MasterPlaylist) Encode() *bytes.Buffer {
}
}

var altsWritten = make(map[string]bool)
var altsWritten = make(map[string]struct{})

for _, pl := range p.Variants {
if pl.Alternatives != nil {
for _, alt := range pl.Alternatives {
// Make sure that we only write out an alternative once
altKey := fmt.Sprintf("%s-%s-%s-%s-%s", alt.Type, alt.GroupId, alt.Name, alt.Language, alt.URI)
if altsWritten[altKey] {
if _, alreadyWritten := altsWritten[altKey]; alreadyWritten {
continue
}
altsWritten[altKey] = true
altsWritten[altKey] = struct{}{}

p.buf.WriteString("#EXT-X-MEDIA:")
if alt.Type != "" {
Expand Down

0 comments on commit db489ea

Please sign in to comment.