Skip to content

Commit

Permalink
refactor(thrift): rm unnecessary args from MessageBeginLength
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaost committed Jul 31, 2024
1 parent c4fad10 commit a1bd708
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions protocol/thrift/binary.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ func appendUint64(buf []byte, v uint64) []byte {

// Length methods

func (BinaryProtocol) MessageBeginLength(name string, _ TMessageType, _ int32) int {
return 4 + (4 + len(name)) + 4
func (BinaryProtocol) MessageBeginLength(method string) int {
return 4 + (4 + len(method)) + 4
}

func (BinaryProtocol) FieldBeginLength() int { return 3 }
Expand Down
2 changes: 1 addition & 1 deletion protocol/thrift/binary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func TestBinary(t *testing.T) {

{ // Message
testname, testtyp, testseq := "name", CALL, int32(7)
sz := Binary.MessageBeginLength(testname, testtyp, testseq)
sz := Binary.MessageBeginLength(testname)

b := Binary.AppendMessageBegin([]byte(nil), testname, testtyp, testseq)
require.Equal(t, int(sz), len(b))
Expand Down
2 changes: 1 addition & 1 deletion protocol/thrift/fastcodec.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func MarshalFastMsg(method string, msgType TMessageType, seq int32, msg FastCode
if method == "" {
return nil, errors.New("method not set")
}
sz := Binary.MessageBeginLength(method, msgType, seq) + msg.BLength()
sz := Binary.MessageBeginLength(method) + msg.BLength()
b := dirtmake.Bytes(sz, sz)
i := Binary.WriteMessageBegin(b, method, msgType, seq)
_ = msg.FastWriteNocopy(b[i:], nil)
Expand Down

0 comments on commit a1bd708

Please sign in to comment.