Skip to content

Commit

Permalink
perf: avoid byte slice to string conversion (#2407)
Browse files Browse the repository at this point in the history
* perf: avoid byte slice to string conversion
  • Loading branch information
rahulguptajss authored Oct 6, 2023
1 parent 07e7651 commit 63973bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
8 changes: 2 additions & 6 deletions cmd/tools/rest/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,10 @@ func (c *Client) TraceLogSet(collectorName string, config *node.Node) {

func (c *Client) printRequestAndResponse(req string, response []byte) {
if c.logRest {
res := "<nil>"
if response != nil {
res = string(response)
}
c.Logger.Info().
Str("Request", req).
Str("Response", res).
Msg("")
Bytes("Response", response).
Send()
}
}

Expand Down
8 changes: 2 additions & 6 deletions pkg/api/ontapi/zapi/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,15 +551,11 @@ func (c *Client) TraceLogSet(collectorName string, config *node.Node) {
}

func (c *Client) printRequestAndResponse(req string, response []byte) {
res := "<nil>"
if response != nil {
res = string(response)
}
if req != "" {
c.Logger.Info().
Str("Request", req).
Str("Response", res).
Msg("")
Bytes("Response", response).
Send()
}
}

Expand Down

0 comments on commit 63973bb

Please sign in to comment.