Skip to content

Commit 3ad701f

Browse files
fix: remove duplicate reverse property and dead _build_reverse method
The optimizer added a second 'reverse' property at the bottom of CallGraph that shadowed the existing one (F811), leaving the original as dead code. Remove the duplicate and the unnecessary _build_reverse helper; the existing reverse property via _build_adjacency is sufficient.
1 parent 4936204 commit 3ad701f

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

codeflash/models/call_graph.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def descendants(self, node: FunctionNode, max_depth: int | None = None) -> set[F
9999
def ancestors(self, node: FunctionNode, max_depth: int | None = None) -> set[FunctionNode]:
100100
visited: set[FunctionNode] = set()
101101
reverse_map = self.reverse
102-
102+
103103
if max_depth is None:
104104
queue: deque[FunctionNode] = deque([node])
105105
while queue:
@@ -118,7 +118,7 @@ def ancestors(self, node: FunctionNode, max_depth: int | None = None) -> set[Fun
118118
if edge.caller not in visited:
119119
visited.add(edge.caller)
120120
queue_with_depth.append((edge.caller, depth + 1))
121-
121+
122122
return visited
123123

124124
def subgraph(self, nodes: set[FunctionNode]) -> CallGraph:
@@ -161,20 +161,6 @@ def topological_order(self) -> list[FunctionNode]:
161161
result.reverse()
162162
return result
163163

164-
def _build_reverse(self) -> dict[FunctionNode, list[CallEdge]]:
165-
rev: dict[FunctionNode, list[CallEdge]] = {}
166-
for e in self.edges:
167-
rev.setdefault(e.callee, []).append(e)
168-
return rev
169-
170-
@property
171-
def reverse(self) -> dict[FunctionNode, list[CallEdge]]:
172-
rv = self._reverse
173-
if rv is None:
174-
rv = self._build_reverse()
175-
self._reverse = rv
176-
return rv
177-
178164

179165
def augment_with_trace(graph: CallGraph, trace_db_path: Path) -> CallGraph:
180166
import sqlite3

0 commit comments

Comments
 (0)