Skip to content

Commit

Permalink
Remove redundant work when validating unary Connect response (connect…
Browse files Browse the repository at this point in the history
…rpc#683)

We can swap TrimPrefix for just a string slice here since we're already
guarding behind HasPrefix. TrimPrefix internally runs HasPrefix again,
so we can just skip the redundant work.
  • Loading branch information
mattrobenolt authored Feb 9, 2024
1 parent b84b000 commit 4524c7d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion protocol_connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ func (cc *connectUnaryClientConn) validateResponse(response *http.Response) *Err
cc.responseHeader[k] = v
continue
}
cc.responseTrailer[strings.TrimPrefix(k, connectUnaryTrailerPrefix)] = v
cc.responseTrailer[k[len(connectUnaryTrailerPrefix):]] = v
}
if err := connectValidateUnaryResponseContentType(
cc.marshaler.codec.Name(),
Expand Down

0 comments on commit 4524c7d

Please sign in to comment.