]> Cypherpunks repositories - gostls13.git/commitdiff
archive: use predeclared function min
authorqiulaidongfeng <2645477756@qq.com>
Tue, 1 Aug 2023 05:08:08 +0000 (05:08 +0000)
committerGopher Robot <gobot@golang.org>
Thu, 3 Aug 2023 15:57:21 +0000 (15:57 +0000)
Change-Id: I23e0005071fcbafeaecaa05f51712dd1de6eed01

Change-Id: I23e0005071fcbafeaecaa05f51712dd1de6eed01
GitHub-Last-Rev: 364d7c74fef1668930b730b05a7539f7ac43e60a
GitHub-Pull-Request: golang/go#61661
Reviewed-on: https://go-review.googlesource.com/c/go/+/514215
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

src/archive/tar/common.go
src/archive/zip/writer.go
src/archive/zip/zip_test.go

index dc9d350eb72791ad7af299bea379f2794e8cda77..d26463501ba06513e3e31a48ae755ba90037a2a0 100644 (file)
@@ -727,10 +727,3 @@ func isHeaderOnlyType(flag byte) bool {
                return false
        }
 }
-
-func min(a, b int64) int64 {
-       if a < b {
-               return a
-       }
-       return b
-}
index 0e81c6a5d7c71396d1744fa2c95f6c4f511ce3f8..3da5ad612b8c44fa9ac9147d94342412ed2cbf91 100644 (file)
@@ -406,8 +406,8 @@ func writeHeader(w io.Writer, h *header) error {
        // flags.
        if h.raw && !h.hasDataDescriptor() {
                b.uint32(h.CRC32)
-               b.uint32(uint32(min64(h.CompressedSize64, uint32max)))
-               b.uint32(uint32(min64(h.UncompressedSize64, uint32max)))
+               b.uint32(uint32(min(h.CompressedSize64, uint32max)))
+               b.uint32(uint32(min(h.UncompressedSize64, uint32max)))
        } else {
                // When this package handle the compression, these values are
                // always written to the trailing data descriptor.
@@ -427,13 +427,6 @@ func writeHeader(w io.Writer, h *header) error {
        return err
 }
 
-func min64(x, y uint64) uint64 {
-       if x < y {
-               return x
-       }
-       return y
-}
-
 // CreateRaw adds a file to the zip archive using the provided FileHeader and
 // returns a Writer to which the file contents should be written. The file's
 // contents must be written to the io.Writer before the next call to Create,
@@ -445,8 +438,8 @@ func (w *Writer) CreateRaw(fh *FileHeader) (io.Writer, error) {
                return nil, err
        }
 
-       fh.CompressedSize = uint32(min64(fh.CompressedSize64, uint32max))
-       fh.UncompressedSize = uint32(min64(fh.UncompressedSize64, uint32max))
+       fh.CompressedSize = uint32(min(fh.CompressedSize64, uint32max))
+       fh.UncompressedSize = uint32(min(fh.UncompressedSize64, uint32max))
 
        h := &header{
                FileHeader: fh,
index 7d1de07c98656d6f9800ef2371b82de78d63df6f..f53d1b9913200fa92deff5eb23137b9b41177aa8 100644 (file)
@@ -198,13 +198,6 @@ func (r *rleBuffer) Write(p []byte) (n int, err error) {
        return len(p), nil
 }
 
-func min(x, y int64) int64 {
-       if x < y {
-               return x
-       }
-       return y
-}
-
 func memset(a []byte, b byte) {
        if len(a) == 0 {
                return