Skip to content

Commit dcf6f08

Browse files
committed
kill the old funky can_reach fn
1 parent 4b1d3b7 commit dcf6f08

File tree

1 file changed

+0
-43
lines changed

1 file changed

+0
-43
lines changed

src/librustc/util/common.rs

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -203,49 +203,6 @@ pub fn block_query<P>(b: &ast::Block, p: P) -> bool where P: FnMut(&ast::Expr) -
203203
return v.flag;
204204
}
205205

206-
/// K: Eq + Hash<S>, V, S, H: Hasher<S>
207-
///
208-
/// Determines whether there exists a path from `source` to `destination`. The
209-
/// graph is defined by the `edges_map`, which maps from a node `S` to a list of
210-
/// its adjacent nodes `T`.
211-
///
212-
/// Efficiency note: This is implemented in an inefficient way because it is
213-
/// typically invoked on very small graphs. If the graphs become larger, a more
214-
/// efficient graph representation and algorithm would probably be advised.
215-
pub fn can_reach<T, S>(edges_map: &HashMap<T, Vec<T>, S>, source: T,
216-
destination: T) -> bool
217-
where S: HashState, T: Hash + Eq + Clone,
218-
{
219-
if source == destination {
220-
return true;
221-
}
222-
223-
// Do a little breadth-first-search here. The `queue` list
224-
// doubles as a way to detect if we've seen a particular FR
225-
// before. Note that we expect this graph to be an *extremely
226-
// shallow* tree.
227-
let mut queue = vec!(source);
228-
let mut i = 0;
229-
while i < queue.len() {
230-
match edges_map.get(&queue[i]) {
231-
Some(edges) => {
232-
for target in edges {
233-
if *target == destination {
234-
return true;
235-
}
236-
237-
if !queue.iter().any(|x| x == target) {
238-
queue.push((*target).clone());
239-
}
240-
}
241-
}
242-
None => {}
243-
}
244-
i += 1;
245-
}
246-
return false;
247-
}
248-
249206
/// Memoizes a one-argument closure using the given RefCell containing
250207
/// a type implementing MutableMap to serve as a cache.
251208
///

0 commit comments

Comments
 (0)