Skip to content

Commit

Permalink
Rewrite some loops to use range.
Browse files Browse the repository at this point in the history
  • Loading branch information
wddevries authored and hawkingrei committed Nov 27, 2024
1 parent 4719db2 commit 5368a64
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/util/workloadrepo/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (w *worker) startSnapshot(_ctx context.Context) func() {
continue
}

for i := 0; i < 5; i++ {
for range 5 {
snapID, err := w.getSnapID(ctx)
if err != nil {
logutil.BgLogger().Info("workload repository cannot get current snapid", zap.NamedError("err", err))
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/workloadrepo/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func checkTableExistsByIS(ctx context.Context, is infoschema.InfoSchema, tblName
}

tbInfo := tbSchema.Meta()
for i := 0; i < 2; i++ {
for i := range 2 {
newPtTime := now.AddDate(0, 0, i+1)
newPtName := "p" + newPtTime.Format("20060102")
ptInfos := tbInfo.GetPartitionInfo().Definitions
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/workloadrepo/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func generatePartitionRanges(sb *strings.Builder, tbInfo *model.TableInfo) bool
// add new partitions per day
// if all partitions to be added existed, do nothing
allExisted := true
for i := 0; i < newPtNum; i++ {
for i := range newPtNum {
// TODO: should we make this UTC? timezone issues
newPtTime := now.AddDate(0, 0, i+1)
newPtName := "p" + newPtTime.Format("20060102")
Expand Down

0 comments on commit 5368a64

Please sign in to comment.