Skip to content

Commit f7941d3

Browse files
authored
Trivial refactor (#4087)
Signed-off-by: socialsister <[email protected]>
1 parent 217c3ce commit f7941d3

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

x/sync/manager.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,10 +1030,7 @@ func (m *Manager) enqueueWork(work *workItem) {
10301030
func midPoint(startMaybe, endMaybe maybe.Maybe[[]byte]) maybe.Maybe[[]byte] {
10311031
start := startMaybe.Value()
10321032
end := endMaybe.Value()
1033-
length := len(start)
1034-
if len(end) > length {
1035-
length = len(end)
1036-
}
1033+
length := max(len(end), len(start))
10371034

10381035
if length == 0 {
10391036
if endMaybe.IsNothing() {
@@ -1180,10 +1177,8 @@ func calculateBackoff(attempt int) time.Duration {
11801177
return 0
11811178
}
11821179

1183-
retryWait := initialRetryWait * time.Duration(math.Pow(retryWaitFactor, float64(attempt)))
1184-
if retryWait > maxRetryWait {
1185-
retryWait = maxRetryWait
1186-
}
1187-
1188-
return retryWait
1180+
return min(
1181+
initialRetryWait*time.Duration(math.Pow(retryWaitFactor, float64(attempt))),
1182+
maxRetryWait,
1183+
)
11891184
}

0 commit comments

Comments
 (0)