]> Cypherpunks repositories - gostls13.git/commitdiff
database/sql: remove a couple redundancies
authordchenk <dcherchenko@gmail.com>
Thu, 12 Apr 2018 02:20:10 +0000 (19:20 -0700)
committerDaniel Theophanes <kardianos@gmail.com>
Thu, 12 Apr 2018 19:23:46 +0000 (19:23 +0000)
This commit includes efficiency improvements in two places in the
database/sql package where an "if err != nil" was redundant and
the error can be returned as-is (most of the code in the standard
library and even in the file I changed does it my suggested way).

Change-Id: Ib9dac69ed01ee846e570a776164cb87c2caee6ca
Reviewed-on: https://go-review.googlesource.com/106555
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/database/sql/sql.go

index beccf7fec1fe1e43f8f38abfebec19facec3ced2..d192dd95b89327c02beeaea210ebf0e6c3ccba86 100644 (file)
@@ -2455,17 +2455,11 @@ func (s *Stmt) Query(args ...interface{}) (*Rows, error) {
 func rowsiFromStatement(ctx context.Context, ci driver.Conn, ds *driverStmt, args ...interface{}) (driver.Rows, error) {
        ds.Lock()
        defer ds.Unlock()
-
        dargs, err := driverArgsConnLocked(ci, ds, args)
        if err != nil {
                return nil, err
        }
-
-       rowsi, err := ctxDriverStmtQuery(ctx, ds.si, dargs)
-       if err != nil {
-               return nil, err
-       }
-       return rowsi, nil
+       return ctxDriverStmtQuery(ctx, ds.si, dargs)
 }
 
 // QueryRowContext executes a prepared query statement with the given arguments.
@@ -2986,11 +2980,7 @@ func (r *Row) Scan(dest ...interface{}) error {
                return err
        }
        // Make sure the query can be processed to completion with no errors.
-       if err := r.rows.Close(); err != nil {
-               return err
-       }
-
-       return nil
+       return r.rows.Close()
 }
 
 // A Result summarizes an executed SQL command.