You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by go...@apache.org on 2021/05/10 10:32:04 UTC
[incubator-inlong] 11/12: Address review comments
This is an automated email from the ASF dual-hosted git repository.
gosonzhang pushed a commit to branch INLONG-25
in repository https://gitbox.apache.org/repos/asf/incubator-inlong.git
commit a16216d6eebb16cecaafc9d96d03ca58919ca611
Author: Zijie Lu <ws...@gmail.com>
AuthorDate: Fri May 7 10:43:11 2021 +0800
Address review comments
Signed-off-by: Zijie Lu <ws...@gmail.com>
---
tubemq-client-twins/tubemq-client-go/codec/tubemq_codec.go | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/tubemq-client-twins/tubemq-client-go/codec/tubemq_codec.go b/tubemq-client-twins/tubemq-client-go/codec/tubemq_codec.go
index 96ebfa9..a8706da 100644
--- a/tubemq-client-twins/tubemq-client-go/codec/tubemq_codec.go
+++ b/tubemq-client-twins/tubemq-client-go/codec/tubemq_codec.go
@@ -25,6 +25,7 @@ import (
"encoding/binary"
"errors"
"io"
+ "math"
)
const (
@@ -86,7 +87,7 @@ func (t *TubeMQDecoder) Decode() (Response, error) {
s := int(binary.BigEndian.Uint32(size))
if totalLen+s > len(t.msg) {
data := t.msg[:totalLen]
- t.msg = make([]byte, 0, max(2*len(t.msg), totalLen+s))
+ t.msg = make([]byte, 0, int(math.Max(float64(2*len(t.msg)), float64(totalLen+s))))
copy(t.msg, data[:])
}
@@ -129,10 +130,3 @@ func (t TubeMQResponse) GetSerialNo() uint32 {
func (t TubeMQResponse) GetBuffer() []byte {
return t.Buffer
}
-
-func max(x, y int) int {
- if x < y {
- return y
- }
- return x
-}