Skip to content

Commit 17304bf

Browse files
committed
Rewrite some loops to use range.
1 parent 86ec1aa commit 17304bf

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

pkg/util/workloadrepo/snapshot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func (w *worker) startSnapshot(_ctx context.Context) func() {
154154
continue
155155
}
156156

157-
for i := 0; i < 5; i++ {
157+
for range 5 {
158158
snapID, err := w.getSnapID(ctx)
159159
if err != nil {
160160
logutil.BgLogger().Info("workload repository cannot get current snapid", zap.NamedError("err", err))

pkg/util/workloadrepo/table.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ func checkTableExistsByIS(ctx context.Context, is infoschema.InfoSchema, tblName
168168
}
169169

170170
tbInfo := tbSchema.Meta()
171-
for i := 0; i < 2; i++ {
171+
for i := range 2 {
172172
newPtTime := now.AddDate(0, 0, i+1)
173173
newPtName := "p" + newPtTime.Format("20060102")
174174
ptInfos := tbInfo.GetPartitionInfo().Definitions

pkg/util/workloadrepo/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func generatePartitionRanges(sb *strings.Builder, tbInfo *model.TableInfo) bool
3838
// add new partitions per day
3939
// if all partitions to be added existed, do nothing
4040
allExisted := true
41-
for i := 0; i < newPtNum; i++ {
41+
for i := range newPtNum {
4242
// TODO: should we make this UTC? timezone issues
4343
newPtTime := now.AddDate(0, 0, i+1)
4444
newPtName := "p" + newPtTime.Format("20060102")

0 commit comments

Comments
 (0)