Skip to content

Commit 416f6f7

Browse files
committed
---
yaml --- r: 41294 b: refs/heads/snap-stage3 c: 8cb17ad h: refs/heads/master v: v3
1 parent 86cb5ec commit 416f6f7

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 09bb07bed9166105ea961a42b5fff7739ae0d2e9
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 226cd68f13339ae02e606957ebd1d2a3fb1e7aad
4+
refs/heads/snap-stage3: 8cb17ad0fa983e60c9bcaba75322a7057449df52
55
refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/rt/rust_crate_map.cpp

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
#include "rust_crate_map.h"
12+
#include <set>
1213

1314
void iter_module_map(const mod_entry* map,
1415
void (*fn)(const mod_entry* entry, void *cookie),
@@ -20,18 +21,27 @@ void iter_module_map(const mod_entry* map,
2021

2122
void iter_crate_map(const cratemap* map,
2223
void (*fn)(const mod_entry* map, void *cookie),
23-
void *cookie) {
24-
// First iterate this crate
25-
iter_module_map(map->entries(), fn, cookie);
26-
// Then recurse on linked crates
27-
// FIXME (#2673) this does double work in diamond-shaped deps. could
28-
// keep a set of visited addresses, if it turns out to be actually
29-
// slow
30-
for (cratemap::iterator i = map->begin(), e = map->end(); i != e; ++i) {
31-
iter_crate_map(*i, fn, cookie);
24+
void *cookie,
25+
std::set<const cratemap*>& visited) {
26+
if (visited.find(map) == visited.end()) {
27+
// Mark this crate visited
28+
visited.insert(map);
29+
// First iterate this crate
30+
iter_module_map(map->entries(), fn, cookie);
31+
// Then recurse on linked crates
32+
for (cratemap::iterator i = map->begin(),
33+
e = map->end(); i != e; ++i) {
34+
iter_crate_map(*i, fn, cookie, visited);
35+
}
3236
}
3337
}
3438

39+
void iter_crate_map(const cratemap* map,
40+
void (*fn)(const mod_entry* map, void *cookie),
41+
void *cookie) {
42+
std::set<const cratemap*> visited;
43+
iter_crate_map(map, fn, cookie, visited);
44+
}
3545
//
3646
// Local Variables:
3747
// mode: C++

0 commit comments

Comments
 (0)