Skip to content

Commit 04b3ab6

Browse files
committed
Encode items before encoding the list of AllocIds
1 parent 6f251c2 commit 04b3ab6

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/librustc_metadata/encoder.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -445,12 +445,24 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
445445

446446
let tcx = self.tcx;
447447

448+
// Encode the items.
449+
i = self.position();
450+
let items = self.encode_info_for_items();
451+
let item_bytes = self.position() - i;
452+
448453
// Encode the allocation index
449454
let interpret_alloc_index = {
450455
let mut interpret_alloc_index = Vec::new();
451456
let mut n = 0;
457+
trace!("beginning to encode alloc ids");
452458
loop {
453459
let new_n = self.interpret_alloc_ids.len();
460+
// if we have found new ids, serialize those, too
461+
if n == new_n {
462+
// otherwise, abort
463+
break;
464+
}
465+
trace!("encoding {} further alloc ids", new_n - n);
454466
for idx in n..new_n {
455467
let id = self.interpret_allocs_inverse[idx];
456468
let pos = self.position() as u32;
@@ -461,21 +473,12 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
461473
id,
462474
).unwrap();
463475
}
464-
// if we have found new ids, serialize those, too
465-
if n == new_n {
466-
// otherwise, abort
467-
break;
468-
}
469476
n = new_n;
470477
}
471478
self.lazy_seq(interpret_alloc_index)
472479
};
473480

474-
// Encode and index the items.
475-
i = self.position();
476-
let items = self.encode_info_for_items();
477-
let item_bytes = self.position() - i;
478-
481+
// Index the items
479482
i = self.position();
480483
let index = items.write_index(&mut self.opaque.cursor);
481484
let index_bytes = self.position() - i;

0 commit comments

Comments
 (0)