test: avoid cooldown expiry sort allocation · openclaw/openclaw@64e731b
shakkernerd
·
2026-05-09
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -131,9 +131,15 @@ const authRuntimeMock = vi.hoisted(() => {
|
131 | 131 | continue; |
132 | 132 | } |
133 | 133 | const stats = store.usageStats?.[profileId]; |
134 | | -const expiry = [stats?.cooldownUntil, stats?.disabledUntil] |
135 | | -.filter((value): value is number => isActive(value, ts)) |
136 | | -.toSorted((a, b) => a - b)[0]; |
| 134 | +const cooldownUntil = stats?.cooldownUntil; |
| 135 | +const disabledUntil = stats?.disabledUntil; |
| 136 | +let expiry: number | undefined; |
| 137 | +if (isActive(cooldownUntil, ts)) { |
| 138 | +expiry = cooldownUntil; |
| 139 | +} |
| 140 | +if (isActive(disabledUntil, ts) && (expiry === undefined || disabledUntil < expiry)) { |
| 141 | +expiry = disabledUntil; |
| 142 | +} |
137 | 143 | if (expiry !== undefined && (soonest === null || expiry < soonest)) { |
138 | 144 | soonest = expiry; |
139 | 145 | } |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。