Skip to content

Commit

Permalink
status: avoid allocations when returning an OK status (#2929)
Browse files Browse the repository at this point in the history
  • Loading branch information
dzbarsky authored and dfawley committed Jul 24, 2019
1 parent decb438 commit 5da5b1f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func FromProto(s *spb.Status) *Status {
// Status is returned with codes.Unknown and the original error message.
func FromError(err error) (s *Status, ok bool) {
if err == nil {
return &Status{s: &spb.Status{Code: int32(codes.OK)}}, true
return nil, true
}
if se, ok := err.(interface {
GRPCStatus() *Status
Expand Down Expand Up @@ -206,7 +206,7 @@ func Code(err error) codes.Code {
func FromContextError(err error) *Status {
switch err {
case nil:
return New(codes.OK, "")
return nil
case context.DeadlineExceeded:
return New(codes.DeadlineExceeded, err.Error())
case context.Canceled:
Expand Down

0 comments on commit 5da5b1f

Please sign in to comment.