@@ -105,22 +105,21 @@ impl AbsoluteBytePos {
105
105
106
106
impl < ' sess > OnDiskCache < ' sess > {
107
107
/// Creates a new OnDiskCache instance from the serialized data in `data`.
108
- pub fn new ( sess : & ' sess Session , data : Vec < u8 > , start_pos : usize ) -> OnDiskCache < ' sess > {
108
+ pub fn new ( sess : & ' sess Session , data : Vec < u8 > ) -> OnDiskCache < ' sess > {
109
109
debug_assert ! ( sess. opts. incremental. is_some( ) ) ;
110
110
111
111
// Wrapping in a scope so we can borrow `data`
112
112
let footer: Footer = {
113
- let mut decoder = opaque:: Decoder :: new ( & data[ ..] , start_pos) ;
114
-
115
113
// Decode the *position* of the footer which can be found in the
116
114
// last 8 bytes of the file.
117
- decoder. set_position ( data. len ( ) - IntEncodedWithFixedSize :: ENCODED_SIZE ) ;
115
+ let mut decoder = opaque:: Decoder :: new (
116
+ & data, data. len ( ) - IntEncodedWithFixedSize :: ENCODED_SIZE ) ;
118
117
let query_result_index_pos = IntEncodedWithFixedSize :: decode ( & mut decoder)
119
118
. expect ( "Error while trying to decode query result index position." )
120
119
. 0 as usize ;
121
120
122
121
// Decoder the file footer which contains all the lookup tables, etc.
123
- decoder. set_position ( query_result_index_pos) ;
122
+ decoder = opaque :: Decoder :: new ( & data , query_result_index_pos) ;
124
123
decode_tagged ( & mut decoder, TAG_FILE_FOOTER )
125
124
. expect ( "Error while trying to decode query result index position." )
126
125
} ;
@@ -540,7 +539,7 @@ impl<'a, 'tcx: 'a, 'x> ty_codec::TyDecoder<'a, 'tcx> for CacheDecoder<'a, 'tcx,
540
539
541
540
#[ inline]
542
541
fn peek_byte ( & self ) -> u8 {
543
- self . opaque . data [ self . opaque . position ( ) ]
542
+ self . opaque . data ( ) [ 0 ]
544
543
}
545
544
546
545
fn cached_ty_for_shorthand < F > ( & mut self ,
@@ -569,9 +568,9 @@ impl<'a, 'tcx: 'a, 'x> ty_codec::TyDecoder<'a, 'tcx> for CacheDecoder<'a, 'tcx,
569
568
fn with_position < F , R > ( & mut self , pos : usize , f : F ) -> R
570
569
where F : FnOnce ( & mut Self ) -> R
571
570
{
572
- debug_assert ! ( pos < self . opaque. data . len( ) ) ;
571
+ debug_assert ! ( pos < self . opaque. original_data . len( ) ) ;
573
572
574
- let new_opaque = opaque:: Decoder :: new ( self . opaque . data , pos) ;
573
+ let new_opaque = opaque:: Decoder :: new ( & self . opaque . original_data , pos) ;
575
574
let old_opaque = mem:: replace ( & mut self . opaque , new_opaque) ;
576
575
let r = f ( self ) ;
577
576
self . opaque = old_opaque;
0 commit comments