Skip to content

Commit ae7a616

Browse files
kenny-not-deadr.sergeev
andauthored
Replace manual nested if-blocks with the built-in min and max functions introduced in Go 1.21 (#2280)
Co-authored-by: r.sergeev <r.sergeev@yadro.com>
1 parent 79a82f9 commit ae7a616

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

excelize.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -170,16 +170,10 @@ func newFile() *File {
170170
// reader.
171171
func (f *File) checkOpenReaderOptions() error {
172172
if f.options.UnzipSizeLimit == 0 {
173-
f.options.UnzipSizeLimit = UnzipSizeLimit
174-
if f.options.UnzipXMLSizeLimit > f.options.UnzipSizeLimit {
175-
f.options.UnzipSizeLimit = f.options.UnzipXMLSizeLimit
176-
}
173+
f.options.UnzipSizeLimit = max(f.options.UnzipXMLSizeLimit, UnzipSizeLimit)
177174
}
178175
if f.options.UnzipXMLSizeLimit == 0 {
179-
f.options.UnzipXMLSizeLimit = StreamChunkSize
180-
if f.options.UnzipSizeLimit < f.options.UnzipXMLSizeLimit {
181-
f.options.UnzipXMLSizeLimit = f.options.UnzipSizeLimit
182-
}
176+
f.options.UnzipXMLSizeLimit = min(f.options.UnzipSizeLimit, StreamChunkSize)
183177
}
184178
if f.options.UnzipXMLSizeLimit > f.options.UnzipSizeLimit {
185179
return ErrOptionsUnzipSizeLimit

0 commit comments

Comments
 (0)