Skip to content

Commit

Permalink
Use struct{} for unused map values
Browse files Browse the repository at this point in the history
  • Loading branch information
vvidic committed Jul 22, 2020
1 parent 2ec752c commit 3a039ee
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mjpeg-proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ type PubSub struct {
pubChan chan []byte
subChan chan *Subscriber
unsubChan chan *Subscriber
subscribers map[*Subscriber]bool
subscribers map[*Subscriber]struct{}
}

func NewPubSub(id string, chunker *Chunker) *PubSub {
Expand All @@ -221,7 +221,7 @@ func NewPubSub(id string, chunker *Chunker) *PubSub {
pubSub.chunker = chunker
pubSub.subChan = make(chan *Subscriber)
pubSub.unsubChan = make(chan *Subscriber)
pubSub.subscribers = make(map[*Subscriber]bool)
pubSub.subscribers = make(map[*Subscriber]struct{})

return pubSub
}
Expand Down Expand Up @@ -270,7 +270,7 @@ func (pubSub *PubSub) doPublish(data []byte) {
}

func (pubSub *PubSub) doSubscribe(s *Subscriber) {
pubSub.subscribers[s] = true
pubSub.subscribers[s] = struct{}{}

fmt.Printf("pubsub[%s]: added subscriber %s (total=%d)\n",
pubSub.id, s.RemoteAddr, len(pubSub.subscribers))
Expand Down

0 comments on commit 3a039ee

Please sign in to comment.