forked from quic-go/quic-go
use sort.Slice to sort the tags in the handshake message
sort.Slice was added in Go 1.8. Now that we've dropped support for Go 1.7, we can make use of it.
This commit is contained in:
@@ -127,10 +127,3 @@ func WriteUint24(b *bytes.Buffer, i uint32) {
|
||||
func WriteUint16(b *bytes.Buffer, i uint16) {
|
||||
b.Write([]byte{uint8(i), uint8(i >> 8)})
|
||||
}
|
||||
|
||||
// Uint32Slice attaches the methods of sort.Interface to []uint32, sorting in increasing order.
|
||||
type Uint32Slice []uint32
|
||||
|
||||
func (s Uint32Slice) Len() int { return len(s) }
|
||||
func (s Uint32Slice) Less(i, j int) bool { return s[i] < s[j] }
|
||||
func (s Uint32Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||
|
||||
@@ -3,7 +3,6 @@ package utils
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"sort"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
@@ -194,10 +193,4 @@ var _ = Describe("Utils", func() {
|
||||
Expect(err).To(HaveOccurred())
|
||||
})
|
||||
})
|
||||
|
||||
It("sorts uint32 slices", func() {
|
||||
s := Uint32Slice{1, 5, 2, 4, 3}
|
||||
sort.Sort(s)
|
||||
Expect(s).To(Equal(Uint32Slice{1, 2, 3, 4, 5}))
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user