Commit 8a85ce2
committed
Fix inefficient duplicate iteration in calculateFreebuffStreak
The calculateFreebuffStreak function was iterating through usageDates twice:
1. Once with filter() to build the usageDateSet
2. Once with reduce() to find lastUsageDate
This is O(2n) when it could be O(n) by combining both operations in a single loop.
The fix combines both operations into one loop, building the set and tracking
the latest date simultaneously. This is more efficient and clearer in intent.1 parent 0444c4c commit 8a85ce2
1 file changed
Lines changed: 9 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
74 | 76 | | |
75 | 77 | | |
76 | 78 | | |
| |||
0 commit comments