Skip to content

Commit

Permalink
perf: remove one useless malloc
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienaury committed Oct 1, 2023
1 parent 297a9c7 commit 4ff6ada
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ Types of changes
- `Fixed` for any bug fixes.
- `Security` in case of vulnerabilities.

## [0.8.0]

- `Added` improvements for global performance (2 times faster).

## [0.7.0]

- `Added` improvements for global performance (2 to 3 times faster).
Expand Down
13 changes: 4 additions & 9 deletions internal/infra/datarowreader_jsonline.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package infra

import (
"bufio"
"errors"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -71,30 +70,26 @@ func (drr *DataRowReaderJSONLine) Close() error {
}

func (drr *DataRowReaderWriterJSONLine) ReadDataRow() (mimo.DataRow, error) {
var data mimo.DataRow

if drr.input.Scan() {
if drr.output != nil {
if err := drr.writeLine(); err != nil {
return nil, err
}
}

data = mimo.DataRow{}
data := mimo.DataRow{}
if err := json.UnmarshalNoEscape(drr.input.Bytes(), &data); err != nil {
return nil, fmt.Errorf("%w", err)
}

return data, nil
}

if err := drr.input.Err(); err != nil {
if errors.Is(err, io.EOF) {
return nil, nil
}

return nil, fmt.Errorf("%w", err)
}

return data, nil
return nil, nil
}

func (drr *DataRowReaderWriterJSONLine) writeLine() error {
Expand Down

0 comments on commit 4ff6ada

Please sign in to comment.