Commit 1c2f199
authored
perf(backoff): optimize linear backoff using closure (#243)
- Remove lodash dependency for faster property access
- Pre-calculate range in closure to avoid repeated subtraction on each call
- Add early return optimization for constant values (min === max)
- Use modern JS features (default parameters, arrow functions)
The range calculation is moved from the hot path (next() function) to
the closure scope, ensuring it's computed only once when the backoff
function is created rather than on every invocation.1 parent 139ba71 commit 1c2f199
1 file changed
Lines changed: 6 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
6 | 5 | | |
7 | 6 | | |
8 | | - | |
| 7 | + | |
9 | 8 | | |
10 | 9 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
| 10 | + | |
18 | 11 | | |
0 commit comments