Skip to content

Commit

Permalink
Merge pull request #588 from tamird/perf-less
Browse files Browse the repository at this point in the history
transport: performance improvements
  • Loading branch information
iamqizhao committed Mar 29, 2016
2 parents 3c688e3 + 54ac757 commit 877b524
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions transport/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,14 @@ func newRecvBuffer() *recvBuffer {
func (b *recvBuffer) put(r item) {
b.mu.Lock()
defer b.mu.Unlock()
b.backlog = append(b.backlog, r)
select {
case b.c <- b.backlog[0]:
b.backlog = b.backlog[1:]
default:
if len(b.backlog) == 0 {
select {
case b.c <- r:
return
default:
}
}
b.backlog = append(b.backlog, r)
}

func (b *recvBuffer) load() {
Expand Down

0 comments on commit 877b524

Please sign in to comment.