Skip to content

Commit

Permalink
os/exec: Use the built-in function min instead of minInt
Browse files Browse the repository at this point in the history
The built-in function `min` has been implemented and can now be used to replace some manually written `minType` helper functions.

Change-Id: Ie8ffc7881c8652ece752751214f1242bf76a6e7e
GitHub-Last-Rev: 5db344f
GitHub-Pull-Request: #60866
Reviewed-on: https://go-review.googlesource.com/c/go/+/504315
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
  • Loading branch information
apocelipes authored and gopherbot committed Aug 1, 2023
1 parent 840ec05 commit 29253f4
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/os/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ func (w *prefixSuffixSaver) Write(p []byte) (n int, err error) {
// grow larger than w.N. It returns the un-appended suffix of p.
func (w *prefixSuffixSaver) fill(dst *[]byte, p []byte) (pRemain []byte) {
if remain := w.N - len(*dst); remain > 0 {
add := minInt(len(p), remain)
add := min(len(p), remain)
*dst = append(*dst, p[:add]...)
p = p[add:]
}
Expand All @@ -1121,13 +1121,6 @@ func (w *prefixSuffixSaver) Bytes() []byte {
return buf.Bytes()
}

func minInt(a, b int) int {
if a < b {
return a
}
return b
}

// environ returns a best-effort copy of the environment in which the command
// would be run as it is currently configured. If an error occurs in computing
// the environment, it is returned alongside the best-effort copy.
Expand Down

0 comments on commit 29253f4

Please sign in to comment.