Skip to content

Commit

Permalink
remove duplicate nil check separate var
Browse files Browse the repository at this point in the history
  • Loading branch information
yangzhouhan committed Jul 24, 2015
1 parent be4cb2a commit e79ac3c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 23 deletions.
12 changes: 2 additions & 10 deletions call.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,7 @@ func Invoke(ctx context.Context, method string, args, reply interface{}, cc *Cli
return toRPCErr(err)
}
if EnableTracing {
p := &payload{
sent: true,
msg: args,
}
c.traceInfo.tr.LazyLog(p, true)
c.traceInfo.tr.LazyLog(&payload{sent: true, msg: args}, true)
}
stream, err = sendRequest(ctx, cc.dopts.codec, callHdr, t, args, topts)
if err != nil {
Expand All @@ -187,11 +183,7 @@ func Invoke(ctx context.Context, method string, args, reply interface{}, cc *Cli
continue
}
if EnableTracing {
p := &payload{
sent: false,
msg: reply,
}
c.traceInfo.tr.LazyLog(p, true)
c.traceInfo.tr.LazyLog(&payload{sent: false, msg: reply}, true)
}
t.CloseStream(stream, lastErr)
if lastErr != nil {
Expand Down
14 changes: 2 additions & 12 deletions stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,7 @@ func (cs *clientStream) SendMsg(m interface{}) (err error) {
if cs.tracing {
cs.mu.Lock()
if cs.traceInfo.tr != nil {
p := &payload{
sent: true,
msg: m,
}
cs.traceInfo.tr.LazyLog(p, true)
cs.traceInfo.tr.LazyLog(&payload{sent: true, msg: m}, true)
}
cs.mu.Unlock()
}
Expand Down Expand Up @@ -202,13 +198,7 @@ func (cs *clientStream) RecvMsg(m interface{}) (err error) {
if cs.tracing {
cs.mu.Lock()
if cs.traceInfo.tr != nil {
if cs.traceInfo.tr != nil {
p := &payload{
sent: false,
msg: m,
}
cs.traceInfo.tr.LazyLog(p, true)
}
cs.traceInfo.tr.LazyLog(&payload{sent: false, msg: m}, true)
}
cs.mu.Unlock()
}
Expand Down
2 changes: 1 addition & 1 deletion trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (f *firstLine) String() string {

// payload represents an RPC request or response payload.
type payload struct {
sent bool // whether this is a request or response
sent bool // whether this is an outgoing payload
msg interface{} // e.g. a proto.Message
// TODO(dsymonds): add stringifying info to codec, and limit how much we hold here?
}
Expand Down

0 comments on commit e79ac3c

Please sign in to comment.