mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-26 23:30:09 +08:00
perf(connections): reduce snapshot and table allocation churn (#8613)
* perf(connections): reduce snapshot and table allocation churn Reuse unchanged connection lists, sort traffic columns without display snapshots, and suspend the relative-time clock while hidden. Keep rule rows indexed and release resize listeners on unmount. * test(connections): limit coverage to changed behavior Keep snapshot sharing, speed decay, bounded history, numeric sorting, and visibility regression guards. Remove unrelated clear-history and pending-delivery assertions. * test(connections): focus clock regression on timer cost Replace behavioral clock assertions with one resource-count check for shared, hidden, and released intervals. * test(connections): retain only allocation and formatting guards Reduce snapshot and table tests to reference reuse, notification suppression, and visible-row formatting cost. * remove useless test * no need changelog
This commit is contained in:
+11
-8
@@ -34,13 +34,11 @@ const RulesPage = () => {
|
||||
}, [refreshRules, refreshRuleProviders, pageVisible])
|
||||
|
||||
const filteredRules = useMemo(() => {
|
||||
const rulesWithLineNo = rules.map((item, index) => ({
|
||||
...item,
|
||||
// UI-only derived data; keep app context/SWR data immutable
|
||||
lineNo: index + 1,
|
||||
}))
|
||||
|
||||
return rulesWithLineNo.filter((item) => match(item.payload ?? ''))
|
||||
const indices: number[] = []
|
||||
for (let i = 0; i < rules.length; i++) {
|
||||
if (match(rules[i].payload ?? '')) indices.push(i)
|
||||
}
|
||||
return indices
|
||||
}, [rules, match])
|
||||
|
||||
const handleScroll = useCallback((e: Event) => {
|
||||
@@ -90,7 +88,12 @@ const RulesPage = () => {
|
||||
ref={virtuosoRef}
|
||||
count={filteredRules.length}
|
||||
estimateSize={40}
|
||||
renderItem={(i) => <RuleItem value={filteredRules[i]} />}
|
||||
renderItem={(i) => (
|
||||
<RuleItem
|
||||
value={rules[filteredRules[i]]}
|
||||
lineNo={filteredRules[i] + 1}
|
||||
/>
|
||||
)}
|
||||
style={{ flex: 1 }}
|
||||
onScroll={handleScroll}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user