Skip to content

Commit

Permalink
optimize init byte.Buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
mehrdadrad committed Apr 2, 2017
1 parent 994e3a1 commit 5d08e48
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions ipfix/marshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ var mockDecodedMsg = Message{
}

func TestJSONMarshal(t *testing.T) {
buf := bytes.NewBufferString("")
buf := new(bytes.Buffer)
msg := TestMessage{}

b, err := mockDecodedMsg.JSONMarshal(buf)
Expand All @@ -102,7 +102,7 @@ func TestJSONMarshal(t *testing.T) {
}

func TestJSONMarshalDataSets(t *testing.T) {
buf := bytes.NewBufferString("")
buf := new(bytes.Buffer)
msg := TestMessage{}

b, _ := mockDecodedMsg.JSONMarshal(buf)
Expand Down Expand Up @@ -137,7 +137,7 @@ func TestJSONMarshalDataSets(t *testing.T) {
}

func BenchmarkJSONMarshal(b *testing.B) {
buf := bytes.NewBufferString("")
buf := new(bytes.Buffer)

for i := 0; i < b.N; i++ {
mockDecodedMsg.JSONMarshal(buf)
Expand Down
2 changes: 1 addition & 1 deletion vflow/ipfix.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func (i *IPFIX) ipfixWorker(wQuit chan struct{}) {
decodedMsg *ipfix.Message
mirror IPFIXUDPMsg
msg = IPFIXUDPMsg{body: ipfixBuffer.Get().([]byte)}
buf = bytes.NewBufferString("")
buf = new(bytes.Buffer)
err error
ok bool
b []byte
Expand Down

0 comments on commit 5d08e48

Please sign in to comment.