if
statement for single bool judgment GO-R10041019 failpoint.Inject("concurrentBucketHeartbeat", func() {
1020 time.Sleep(500 * time.Millisecond)
1021 })
1022 if ok := region.UpdateBuckets(buckets, old); ok {1023 return nil
1024 }
1025 }
1877 storeLabel := strconv.FormatUint(storeID, 10)
1878
1879 progress := encodePreparingProgressKey(storeID)
1880 if exist := c.progressManager.RemoveProgress(progress); exist {1881 storesProgressGauge.DeleteLabelValues(storeAddress, storeLabel, preparingAction)
1882 storesSpeedGauge.DeleteLabelValues(storeAddress, storeLabel, preparingAction)
1883 storesETAGauge.DeleteLabelValues(storeAddress, storeLabel, preparingAction)
1883 storesETAGauge.DeleteLabelValues(storeAddress, storeLabel, preparingAction)
1884 }
1885 progress = encodeRemovingProgressKey(storeID)
1886 if exist := c.progressManager.RemoveProgress(progress); exist {1887 storesProgressGauge.DeleteLabelValues(storeAddress, storeLabel, removingAction)
1888 storesSpeedGauge.DeleteLabelValues(storeAddress, storeLabel, removingAction)
1889 storesETAGauge.DeleteLabelValues(storeAddress, storeLabel, removingAction)
240 defer cancel()
241 var options []clientv3.OpOption
242 key := string(req.GetKey())
243 if prevKv := req.GetPrevKv(); prevKv {244 options = append(options, clientv3.WithPrevKV())
245 }
246
208 if lease := clientv3.LeaseID(req.GetLease()); lease != 0 {
209 options = append(options, clientv3.WithLease(lease))
210 }
211 if prevKv := req.GetPrevKv(); prevKv {212 options = append(options, clientv3.WithPrevKV())
213 }
214
if
statement can be simplified where only a single bool judgment is happening. It is more
idiomatic not to store the result of a function returning a bool and compare that in if
statement's conditional. It is better to skip the initialization expression.
if ok := fn(); ok {
// body
}
if fn() {
// body
}