File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
sdk/pinocchio/src/sysvars/slot_hashes Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -191,25 +191,25 @@ impl<T: Deref<Target = [u8]>> SlotHashes<T> {
191191 /// the slice is big enough and properly aligned.
192192 #[ inline( always) ]
193193 pub fn entries ( & self ) -> & [ SlotHashEntry ] {
194- let len = self . len ( ) ;
195- debug_assert ! ( self . data. len( ) >= NUM_ENTRIES_SIZE + len * ENTRY_SIZE ) ;
196-
197194 unsafe {
198195 // SAFETY: The slice begins `NUM_ENTRIES_SIZE` bytes into `self.data`, which
199196 // is guaranteed by parse_and_validate_data() to have at least `len * ENTRY_SIZE`
200197 // additional bytes. The pointer is properly aligned for `SlotHashEntry` (which
201198 // a compile-time assertion ensures is alignment 1).
202199 from_raw_parts (
203200 self . data . as_ptr ( ) . add ( NUM_ENTRIES_SIZE ) as * const SlotHashEntry ,
204- len,
201+ self . len ( ) ,
205202 )
206203 }
207204 }
208205
209206 /// Gets a reference to the entry at `index` or `None` if out of bounds.
210207 #[ inline( always) ]
211208 pub fn get_entry ( & self , index : usize ) -> Option < & SlotHashEntry > {
212- self . entries ( ) . get ( index)
209+ if index >= self . len ( ) {
210+ return None ;
211+ }
212+ Some ( unsafe { self . get_entry_unchecked ( index) } )
213213 }
214214
215215 /// Finds the hash for a specific slot using binary search.
You can’t perform that action at this time.
0 commit comments