1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use dep_graph::DepNode;
use ich::Fingerprint;
use rustc_data_structures::indexed_vec::{IndexVec, Idx};
newtype_index!(SerializedDepNodeIndex);
#[derive(Debug, RustcEncodable, RustcDecodable)]
pub struct SerializedDepGraph {
pub nodes: IndexVec<SerializedDepNodeIndex, (DepNode, Fingerprint)>,
pub edge_list_indices: IndexVec<SerializedDepNodeIndex, (u32, u32)>,
pub edge_list_data: Vec<SerializedDepNodeIndex>,
}
impl SerializedDepGraph {
pub fn new() -> SerializedDepGraph {
SerializedDepGraph {
nodes: IndexVec::new(),
edge_list_indices: IndexVec::new(),
edge_list_data: Vec::new(),
}
}
#[inline]
pub fn edge_targets_from(&self,
source: SerializedDepNodeIndex)
-> &[SerializedDepNodeIndex] {
let targets = self.edge_list_indices[source];
&self.edge_list_data[targets.0 as usize..targets.1 as usize]
}
}