]> Cypherpunks.ru repositories - gostls13.git/commitdiff
database/sql: use the built-in min function
authormstmdev <mstmdev@gmail.com>
Mon, 25 Sep 2023 08:43:18 +0000 (08:43 +0000)
committerGopher Robot <gobot@golang.org>
Tue, 3 Oct 2023 19:29:35 +0000 (19:29 +0000)
Change-Id: Ib6a0e1e1583e45e3d239455e8b131c81602b2d5d
GitHub-Last-Rev: dc82635562a7fb4488f374d7a9ed26b29310e918
GitHub-Pull-Request: golang/go#63200
Reviewed-on: https://go-review.googlesource.com/c/go/+/530875
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/database/sql/sql.go

index 7592bad1d385138af1513cf35212e95d462e2244..013c03d97a7c3603d24e49bdec4cc60f39bff007 100644 (file)
@@ -964,12 +964,7 @@ func (db *DB) shortestIdleTimeLocked() time.Duration {
        if db.maxLifetime <= 0 {
                return db.maxIdleTime
        }
-
-       min := db.maxIdleTime
-       if min > db.maxLifetime {
-               min = db.maxLifetime
-       }
-       return min
+       return min(db.maxIdleTime, db.maxLifetime)
 }
 
 // SetMaxIdleConns sets the maximum number of connections in the idle