Skip to content

Commit 5da5b1f

Browse files
dzbarskydfawley
authored andcommitted
status: avoid allocations when returning an OK status (#2929)
1 parent decb438 commit 5da5b1f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: status/status.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func FromProto(s *spb.Status) *Status {
132132
// Status is returned with codes.Unknown and the original error message.
133133
func FromError(err error) (s *Status, ok bool) {
134134
if err == nil {
135-
return &Status{s: &spb.Status{Code: int32(codes.OK)}}, true
135+
return nil, true
136136
}
137137
if se, ok := err.(interface {
138138
GRPCStatus() *Status
@@ -206,7 +206,7 @@ func Code(err error) codes.Code {
206206
func FromContextError(err error) *Status {
207207
switch err {
208208
case nil:
209-
return New(codes.OK, "")
209+
return nil
210210
case context.DeadlineExceeded:
211211
return New(codes.DeadlineExceeded, err.Error())
212212
case context.Canceled:

0 commit comments

Comments
 (0)