Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplifications and cleanups (gosimple) #1996

Merged
merged 4 commits into from
Apr 16, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Simplify make() (gosimple)
This fixes:
benchmark/worker/benchmark_client.go:151:36: should use make([]*grpc.ClientConn, connCount) instead (S1019)
benchmark/worker/benchmark_client.go:231:47: should use make([]lockingHistogram, rpcCountPerConn * len(conns)) instead (S1019)
benchmark/worker/benchmark_client.go:343:39: should use make([]*stats.Histogram, len(bc.lockingHistograms)) instead (S1019)
benchmark/worker/benchmark_client.go:369:22: should use make([]uint32, len(mergedHistogram.Buckets)) instead (S1019)
encoding/encoding.go:85:47: should use make(map[string]Codec) instead (S1019)
proxy_test.go:116:26: should use make([]byte, len(msg)) instead (S1019)
  • Loading branch information
knweiss committed Apr 15, 2018
commit 4d9544a0fd44b5c1da96d3f6c703f4a349580439
8 changes: 4 additions & 4 deletions benchmark/worker/benchmark_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func createConns(config *testpb.ClientConfig) ([]*grpc.ClientConn, func(), error

// Create connections.
connCount := int(config.ClientChannels)
conns := make([]*grpc.ClientConn, connCount, connCount)
conns := make([]*grpc.ClientConn, connCount)
for connIndex := 0; connIndex < connCount; connIndex++ {
conns[connIndex] = benchmark.NewClientConn(config.ServerTargets[connIndex%len(config.ServerTargets)], opts...)
}
Expand Down Expand Up @@ -228,7 +228,7 @@ func startBenchmarkClient(config *testpb.ClientConfig) (*benchmarkClient, error)
BaseBucketSize: (1 + config.HistogramParams.Resolution),
MinValue: 0,
},
lockingHistograms: make([]lockingHistogram, rpcCountPerConn*len(conns), rpcCountPerConn*len(conns)),
lockingHistograms: make([]lockingHistogram, rpcCountPerConn*len(conns)),

stop: make(chan bool),
lastResetTime: time.Now(),
Expand Down Expand Up @@ -340,7 +340,7 @@ func (bc *benchmarkClient) getStats(reset bool) *testpb.ClientStats {
if reset {
// Merging histogram may take some time.
// Put all histograms aside and merge later.
toMerge := make([]*stats.Histogram, len(bc.lockingHistograms), len(bc.lockingHistograms))
toMerge := make([]*stats.Histogram, len(bc.lockingHistograms))
for i := range bc.lockingHistograms {
toMerge[i] = bc.lockingHistograms[i].swap(stats.NewHistogram(bc.histogramOptions))
}
Expand All @@ -366,7 +366,7 @@ func (bc *benchmarkClient) getStats(reset bool) *testpb.ClientStats {
uTimeElapsed, sTimeElapsed = cpuTimeDiff(bc.rusageLastReset, latestRusage)
}

b := make([]uint32, len(mergedHistogram.Buckets), len(mergedHistogram.Buckets))
b := make([]uint32, len(mergedHistogram.Buckets))
for i, v := range mergedHistogram.Buckets {
b[i] = uint32(v.Count)
}
Expand Down
2 changes: 1 addition & 1 deletion encoding/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ type Codec interface {
Name() string
}

var registeredCodecs = make(map[string]Codec, 0)
var registeredCodecs = make(map[string]Codec)

// RegisterCodec registers the provided Codec for use with all gRPC clients and
// servers.
Expand Down
2 changes: 1 addition & 1 deletion proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func TestHTTPConnect(t *testing.T) {
}

msg := []byte{4, 3, 5, 2}
recvBuf := make([]byte, len(msg), len(msg))
recvBuf := make([]byte, len(msg))
done := make(chan struct{})
go func() {
in, err := blis.Accept()
Expand Down