From 354d3b0423be94d57835cee818de3d33759df76b Mon Sep 17 00:00:00 2001 From: Super-long <0x4f4f4f4f@gmail.com> Date: Sat, 7 May 2022 21:58:00 +0800 Subject: [PATCH] fix: Eliminate useless for loops. Signed-off-by: Super-long <0x4f4f4f4f@gmail.com> --- data/experiment.go | 4 ++-- data/preparation.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/data/experiment.go b/data/experiment.go index 38369bf0..f5692075 100644 --- a/data/experiment.go +++ b/data/experiment.go @@ -121,10 +121,10 @@ func (s *Source) ExperimentTableExists() (bool, error) { } defer rows.Close() var c int - for rows.Next() { + if rows.Next() { rows.Scan(&c) - break } + return c != 0, nil } diff --git a/data/preparation.go b/data/preparation.go index 80fa0ca3..dc4496c3 100644 --- a/data/preparation.go +++ b/data/preparation.go @@ -177,10 +177,10 @@ func (s *Source) PreparationTableExists() (bool, error) { } defer rows.Close() var c int - for rows.Next() { + if rows.Next() { rows.Scan(&c) - break } + return c != 0, nil }