Skip to content

Commit

Permalink
Refactor by removing unnecessary else block (#1559)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandear committed May 11, 2023
1 parent 1a46e57 commit eaab8ff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
3 changes: 1 addition & 2 deletions args.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,9 +598,8 @@ func decodeArgAppendNoPlus(dst, src []byte) []byte {
if idx < 0 {
// fast path: src doesn't contain encoded chars
return append(dst, src...)
} else {
dst = append(dst, src[:idx]...)
}
dst = append(dst, src[:idx]...)

// slow path
for i := idx; i < len(src); i++ {
Expand Down
19 changes: 9 additions & 10 deletions streaming.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,15 @@ func (rs *requestStream) Read(p []byte) (int, error) {
return n, io.EOF
}
return n, err
} else {
left := rs.header.ContentLength() - rs.totalBytesRead
if len(p) > left {
p = p[:left]
}
n, err = rs.reader.Read(p)
rs.totalBytesRead += n
if err != nil {
return n, err
}
}
left := rs.header.ContentLength() - rs.totalBytesRead
if len(p) > left {
p = p[:left]
}
n, err = rs.reader.Read(p)
rs.totalBytesRead += n
if err != nil {
return n, err
}

if rs.totalBytesRead == rs.header.ContentLength() {
Expand Down

0 comments on commit eaab8ff

Please sign in to comment.