Skip to content

Commit 9b4c844

Browse files
committed
Decode edges using an iterator.
1 parent 620d16a commit 9b4c844

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

compiler/rustc_query_system/src/dep_graph/graph.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1180,8 +1180,7 @@ impl<K: DepKind> CurrentDepGraph<K> {
11801180
prev_graph.fingerprint_by_index(prev_index),
11811181
prev_graph
11821182
.edge_targets_from(prev_index)
1183-
.iter()
1184-
.map(|i| prev_index_to_index[*i].unwrap())
1183+
.map(|i| prev_index_to_index[i].unwrap())
11851184
.collect(),
11861185
);
11871186
prev_index_to_index[prev_index] = Some(dep_node_index);

compiler/rustc_query_system/src/dep_graph/serialized.rs

+11-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use rustc_data_structures::profiling::SelfProfilerRef;
2323
use rustc_data_structures::sync::Lock;
2424
use rustc_index::vec::IndexVec;
2525
use rustc_serialize::opaque::{FileEncodeResult, FileEncoder, IntEncodedWithFixedSize, MemDecoder};
26-
use rustc_serialize::{Decodable, Encodable};
26+
use rustc_serialize::{Decodable, Decoder, Encodable};
2727
use smallvec::SmallVec;
2828
use std::convert::TryInto;
2929
use std::hash::{Hash, Hasher};
@@ -128,14 +128,20 @@ impl<K: DepKind> SerializedDepGraph<K> {
128128
}
129129

130130
#[inline]
131-
pub fn edge_targets_from(&self, source: SerializedDepNodeIndex) -> Vec<SerializedDepNodeIndex> {
131+
pub fn edge_targets_from(
132+
&self,
133+
source: SerializedDepNodeIndex,
134+
) -> impl Iterator<Item = SerializedDepNodeIndex> + '_ {
132135
// The encoder has checked that there is no padding there.
133-
if let Some(ref mut decoder) = self.decoder_at(source) {
136+
if let Some(mut decoder) = self.decoder_at(source) {
134137
decoder.set_position(std::mem::size_of::<Fingerprint>());
135-
Decodable::decode(decoder)
138+
let len = decoder.read_usize();
139+
Some((0..len).map(move |_| SerializedDepNodeIndex::decode(&mut decoder)))
136140
} else {
137-
Vec::new()
141+
None
138142
}
143+
.into_iter()
144+
.flatten()
139145
}
140146

141147
pub fn node_count(&self) -> usize {

0 commit comments

Comments
 (0)