2
0
mirror of https://github.com/soheilhy/cmux.git synced 2026-08-04 04:47:51 +08:00

remove named returns and useless closures

This commit is contained in:
Tamir Duberstein
2016-02-20 16:16:18 -05:00
committed by Soheil Hassas Yeganeh
parent ecc37f82cd
commit b5e73ea381
2 changed files with 11 additions and 15 deletions

View File

@@ -21,9 +21,7 @@ func Any() Matcher {
// starts with any of the strings in strs.
func PrefixMatcher(strs ...string) Matcher {
pt := newPatriciaTreeString(strs...)
return func(r io.Reader) bool {
return pt.matchPrefix(r)
}
return pt.matchPrefix
}
var defaultHTTPMethods = []string{
@@ -84,9 +82,7 @@ var http2Preface = []byte(http2.ClientPreface)
// HTTP2 parses the frame header of the first frame to detect whether the
// connection is an HTTP2 connection.
func HTTP2() Matcher {
return func(r io.Reader) bool {
return hasHTTP2Preface(r)
}
return hasHTTP2Preface
}
// HTTP1HeaderField returns a matcher matching the header fields of the first
@@ -105,7 +101,7 @@ func HTTP2HeaderField(name, value string) Matcher {
}
}
func hasHTTP2Preface(r io.Reader) (ok bool) {
func hasHTTP2Preface(r io.Reader) bool {
b := make([]byte, len(http2Preface))
n, err := r.Read(b)
if err != nil {