优化: AI Chat全栈多批审查修复与架构清理(risk_level清理/路由解耦/工具渲染/测试补测/死代码)
This commit is contained in:
@@ -101,6 +101,8 @@ impl Dag {
|
||||
for edge in &self.edges {
|
||||
// 仅收录两端均为已注册节点的边,跳过野节点
|
||||
if node_ids.contains(&edge.source) && node_ids.contains(&edge.target) {
|
||||
// safe: edge.target 已在 node_ids 中(上一行 contains 守卫),而 in_degree
|
||||
// 对每个 node_id 都插入了表项(line 97-99 初始化),故 get_mut 必命中
|
||||
*in_degree.get_mut(&edge.target).unwrap() += 1;
|
||||
adjacency_out
|
||||
.entry(edge.source.clone())
|
||||
@@ -127,6 +129,9 @@ impl Dag {
|
||||
// 出边已索引,O(出度) 遍历而非 O(E) 全表扫描
|
||||
if let Some(succs) = adjacency_out.get(&id) {
|
||||
for succ in succs {
|
||||
// safe: succ 来自 adjacency_out,其元素均为通过 line 103 contains 守卫
|
||||
// 的 edge.target(line 108 push),而 in_degree 覆盖所有 node_id(line 97-99),
|
||||
// 故 succ 必在 in_degree 表内,get_mut 必命中
|
||||
let deg = in_degree.get_mut(succ).unwrap();
|
||||
*deg -= 1;
|
||||
if *deg == 0 {
|
||||
|
||||
Reference in New Issue
Block a user