Skip to content

Commit e17b195

Browse files
Refactor restart_backoff_counter
1 parent ce3e14f commit e17b195

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

Include/internal/pycore_backoff.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,11 @@ static inline _Py_BackoffCounter
6565
restart_backoff_counter(_Py_BackoffCounter counter)
6666
{
6767
assert(!is_unreachable_backoff_counter(counter));
68-
int backoff = counter.value_and_backoff & BACKOFF_MASK;
69-
if (backoff < MAX_BACKOFF) {
70-
return make_backoff_counter((1 << (2 * backoff + 3)) - 1, backoff + 1);
71-
}
72-
else {
73-
return make_backoff_counter((1 << (2 * MAX_BACKOFF + 1)) - 1, MAX_BACKOFF);
74-
}
68+
uint16_t backoff = counter.value_and_backoff & BACKOFF_MASK;
69+
assert(backoff <= MAX_BACKOFF);
70+
backoff = (backoff == MAX_BACKOFF) ? backoff : backoff + 1;
71+
uint16_t value = (1 << (2 * backoff + 1)) - 1;
72+
return make_backoff_counter(value, backoff);
7573
}
7674

7775
static inline _Py_BackoffCounter

0 commit comments

Comments
 (0)