cleanup: replace unnecessary loops (#2573)

This commit is contained in:
Doug Fawley
2019-01-16 13:06:58 -08:00
committed by GitHub
parent dfd7708d35
commit 4e92c060da
2 changed files with 3 additions and 11 deletions

View File

@ -822,18 +822,12 @@ func equalLogEntry(entries ...*pb.GrpcLogEntry) (equal bool) {
e.CallId = 0 // CallID is global to the binary, hard to compare. e.CallId = 0 // CallID is global to the binary, hard to compare.
if h := e.GetClientHeader(); h != nil { if h := e.GetClientHeader(); h != nil {
h.Timeout = nil h.Timeout = nil
tmp := h.Metadata.Entry[:0] tmp := append(h.Metadata.Entry[:0], h.Metadata.Entry...)
for _, e := range h.Metadata.Entry {
tmp = append(tmp, e)
}
h.Metadata.Entry = tmp h.Metadata.Entry = tmp
sort.Slice(h.Metadata.Entry, func(i, j int) bool { return h.Metadata.Entry[i].Key < h.Metadata.Entry[j].Key }) sort.Slice(h.Metadata.Entry, func(i, j int) bool { return h.Metadata.Entry[i].Key < h.Metadata.Entry[j].Key })
} }
if h := e.GetServerHeader(); h != nil { if h := e.GetServerHeader(); h != nil {
tmp := h.Metadata.Entry[:0] tmp := append(h.Metadata.Entry[:0], h.Metadata.Entry...)
for _, e := range h.Metadata.Entry {
tmp = append(tmp, e)
}
h.Metadata.Entry = tmp h.Metadata.Entry = tmp
sort.Slice(h.Metadata.Entry, func(i, j int) bool { return h.Metadata.Entry[i].Key < h.Metadata.Entry[j].Key }) sort.Slice(h.Metadata.Entry, func(i, j int) bool { return h.Metadata.Entry[i].Key < h.Metadata.Entry[j].Key })
} }

View File

@ -156,9 +156,7 @@ func setupClient(c *clientConfig) (cc *grpc.ClientConn, r *manual.Resolver, defe
if c.testHealthCheckFuncWrapper != nil { if c.testHealthCheckFuncWrapper != nil {
opts = append(opts, internal.WithHealthCheckFunc.(func(internal.HealthChecker) grpc.DialOption)(c.testHealthCheckFuncWrapper)) opts = append(opts, internal.WithHealthCheckFunc.(func(internal.HealthChecker) grpc.DialOption)(c.testHealthCheckFuncWrapper))
} }
for _, dopt := range c.extraDialOption { opts = append(opts, c.extraDialOption...)
opts = append(opts, dopt)
}
cc, err = grpc.Dial(r.Scheme()+":///test.server", opts...) cc, err = grpc.Dial(r.Scheme()+":///test.server", opts...)
if err != nil { if err != nil {
rcleanup() rcleanup()