Skip to content

Commit b078ece

Browse files
committed
rewrite to pass a ref, not slice + index
1 parent 15507bc commit b078ece

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/librustc_trans/context.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,7 @@ impl<'a, 'tcx: 'a> CrateContextList<'a, 'tcx> {
266266
/// pass around (SharedCrateContext, LocalCrateContext) tuples all over trans.
267267
pub struct CrateContext<'a, 'tcx: 'a> {
268268
shared: &'a SharedCrateContext<'a, 'tcx>,
269-
local_ccxs: &'a [LocalCrateContext<'tcx>],
270-
/// The index of `local` in `local_ccxs`. This is used in
271-
/// `maybe_iter(true)` to identify the original `LocalCrateContext`.
272-
index: usize,
269+
local_ccx: &'a LocalCrateContext<'tcx>,
273270
}
274271

275272
impl<'a, 'tcx> DepGraphSafe for CrateContext<'a, 'tcx> {
@@ -298,8 +295,7 @@ impl<'a, 'tcx> Iterator for CrateContextIterator<'a,'tcx> {
298295

299296
let ccx = CrateContext {
300297
shared: self.shared,
301-
index: index,
302-
local_ccxs: self.local_ccxs,
298+
local_ccx: &self.local_ccxs[index],
303299
};
304300

305301
if
@@ -630,8 +626,7 @@ impl<'tcx> LocalCrateContext<'tcx> {
630626
assert!(local_ccxs.len() == 1);
631627
CrateContext {
632628
shared: shared,
633-
index: 0,
634-
local_ccxs: local_ccxs
629+
local_ccx: &local_ccxs[0]
635630
}
636631
}
637632
}
@@ -642,7 +637,7 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> {
642637
}
643638

644639
fn local(&self) -> &'b LocalCrateContext<'tcx> {
645-
&self.local_ccxs[self.index]
640+
self.local_ccx
646641
}
647642

648643
pub fn tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx, 'tcx> {

0 commit comments

Comments
 (0)