Skip to content

Commit

Permalink
fix: fix the NocopyWriteThreshold check logic (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
YangruiEmma authored Sep 10, 2024
1 parent 024f019 commit 608357f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion protocol/thrift/binary.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (BinaryProtocol) WriteBinary(buf, v []byte) int {
}

func (p BinaryProtocol) WriteBinaryNocopy(buf []byte, w NocopyWriter, v []byte) int {
if w == nil || len(buf) < NocopyWriteThreshold {
if w == nil || len(v) < nocopyWriteThreshold {
return p.WriteBinary(buf, v)
}
binary.BigEndian.PutUint32(buf, uint32(len(v)))
Expand Down
4 changes: 2 additions & 2 deletions protocol/thrift/fastcodec.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import (
"github.com/bytedance/gopkg/lang/dirtmake"
)

// NocopyWriteThreshold represents the threshold of using `NocopyWriter` for binary or string
// nocopyWriteThreshold represents the threshold of using `NocopyWriter` for binary or string
//
// It's used by `WriteBinaryNocopy` and `WriteStringNocopy` of `BinaryProtocol`
// which are relied by kitex tool or thriftgo
var NocopyWriteThreshold = 4096
const nocopyWriteThreshold = 4096

// BinaryWriter represents the method used in thrift encoding for nocopy writes
// It supports netpoll nocopy feature, see: https://github.com/cloudwego/netpoll/blob/develop/nocopy.go
Expand Down

0 comments on commit 608357f

Please sign in to comment.