Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix unnecesssary allocation in infile.go #1600

Merged
merged 1 commit into from
Jun 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions infile.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ const defaultPacketSize = 16 * 1024 // 16KB is small enough for disk readahead a

func (mc *okHandler) handleInFileRequest(name string) (err error) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function is quite lengthy and complex. Consider refactoring into smaller, more focused functions to improve maintainability and testability.

Tools
golangci-lint

96-96: Function 'handleInFileRequest' is too long (86 > 60) (funlen)

var rdr io.Reader
var data []byte
packetSize := defaultPacketSize
if mc.maxWriteSize < packetSize {
packetSize = mc.maxWriteSize
Expand Down Expand Up @@ -147,9 +146,11 @@ func (mc *okHandler) handleInFileRequest(name string) (err error) {
}

// send content packets
var data []byte

// if packetSize == 0, the Reader contains no data
if err == nil && packetSize > 0 {
data := make([]byte, 4+packetSize)
data = make([]byte, 4+packetSize)
var n int
for err == nil {
n, err = rdr.Read(data[4:])
Expand Down
Loading