@@ -266,170 +266,6 @@ pub mod serialization_neu {
266266 & bytes[ lower .. upper]
267267 }
268268
269- // Assembly inspection functions for from_byte_slices vs from_bytes optimization.
270- #[ cfg( not( test) ) ]
271- mod inspect {
272- use crate :: Strings ;
273-
274- type TupleBorrowed < ' a > = ( & ' a [ u64 ] , Strings < & ' a [ u64 ] , & ' a [ u8 ] > , crate :: Vecs < & ' a [ u32 ] , & ' a [ u64 ] > ) ;
275-
276- /// Reconstruct a (u64, String, Vec<u32>) container from byte slices and get the first field at index i.
277- #[ no_mangle]
278- pub fn inspect_from_byte_slices_field0 ( slices : & [ & [ u8 ] ] , index : usize ) -> u64 {
279- use crate :: { FromBytes , Index } ;
280- let container = TupleBorrowed :: from_byte_slices ( slices) ;
281- let ( a, _b, _c) = container. get ( index) ;
282- * a
283- }
284-
285- /// Same but via from_bytes iterator.
286- #[ no_mangle]
287- pub fn inspect_from_bytes_field0 ( slices : & [ & [ u8 ] ] , index : usize ) -> u64 {
288- use crate :: { FromBytes , Index } ;
289- let container = TupleBorrowed :: from_bytes ( & mut slices. iter ( ) . copied ( ) ) ;
290- let ( a, _b, _c) = container. get ( index) ;
291- * a
292- }
293-
294- /// Get the second field (String) via from_byte_slices.
295- #[ no_mangle]
296- pub fn inspect_from_byte_slices_field1 < ' a > ( slices : & [ & ' a [ u8 ] ] , index : usize ) -> & ' a str {
297- use crate :: { FromBytes , Index } ;
298- let container = TupleBorrowed :: from_byte_slices ( slices) ;
299- let ( _a, b, _c) = container. get ( index) ;
300- b
301- }
302-
303- /// Get the second field (String) via from_bytes.
304- #[ no_mangle]
305- pub fn inspect_from_bytes_field1 < ' a > ( slices : & [ & ' a [ u8 ] ] , index : usize ) -> & ' a str {
306- use crate :: { FromBytes , Index } ;
307- let container = TupleBorrowed :: from_bytes ( & mut slices. iter ( ) . copied ( ) ) ;
308- let ( _a, b, _c) = container. get ( index) ;
309- b
310- }
311-
312- // Pure tuple: all &[u64] fields, no validation side effects.
313- type PureTuple < ' a > = ( & ' a [ u64 ] , & ' a [ u64 ] , & ' a [ u64 ] ) ;
314-
315- /// Pure tuple, get field 0 only.
316- #[ no_mangle]
317- pub fn inspect_pure_field0 ( slices : & [ & [ u8 ] ] , index : usize ) -> u64 {
318- use crate :: { FromBytes , Index } ;
319- let container = PureTuple :: from_byte_slices ( slices) ;
320- let ( a, _b, _c) = container. get ( index) ;
321- * a
322- }
323-
324- /// Pure tuple, get field 1 only.
325- #[ no_mangle]
326- pub fn inspect_pure_field1 ( slices : & [ & [ u8 ] ] , index : usize ) -> u64 {
327- use crate :: { FromBytes , Index } ;
328- let container = PureTuple :: from_byte_slices ( slices) ;
329- let ( _a, b, _c) = container. get ( index) ;
330- * b
331- }
332-
333- /// Pure tuple, get all fields.
334- #[ no_mangle]
335- pub fn inspect_pure_all ( slices : & [ & [ u8 ] ] , index : usize ) -> ( u64 , u64 , u64 ) {
336- use crate :: { FromBytes , Index } ;
337- let container = PureTuple :: from_byte_slices ( slices) ;
338- let ( a, b, c) = container. get ( index) ;
339- ( * a, * b, * c)
340- }
341-
342- /// Unsafe: cast &[u8] to &[u64] with no validation.
343- #[ inline( always) ]
344- unsafe fn cast_u64 ( bytes : & [ u8 ] ) -> & [ u64 ] {
345- std:: slice:: from_raw_parts ( bytes. as_ptr ( ) as * const u64 , bytes. len ( ) / 8 )
346- }
347-
348- /// Hand-written field0 access: no panics, no validation.
349- #[ no_mangle]
350- pub unsafe fn inspect_unsafe_field0 ( slices : & [ & [ u8 ] ] , index : usize ) -> u64 {
351- let field0 = cast_u64 ( slices. get_unchecked ( 0 ) ) ;
352- * field0. get_unchecked ( index)
353- }
354-
355- /// Hand-written field1 access: no panics, no validation.
356- #[ no_mangle]
357- pub unsafe fn inspect_unsafe_field1 ( slices : & [ & [ u8 ] ] , index : usize ) -> u64 {
358- let field1 = cast_u64 ( slices. get_unchecked ( 1 ) ) ;
359- * field1. get_unchecked ( index)
360- }
361-
362- /// Hand-written all 3 fields: no panics, no validation.
363- #[ no_mangle]
364- pub unsafe fn inspect_unsafe_all ( slices : & [ & [ u8 ] ] , index : usize ) -> ( u64 , u64 , u64 ) {
365- let f0 = cast_u64 ( slices. get_unchecked ( 0 ) ) ;
366- let f1 = cast_u64 ( slices. get_unchecked ( 1 ) ) ;
367- let f2 = cast_u64 ( slices. get_unchecked ( 2 ) ) ;
368- ( * f0. get_unchecked ( index) , * f1. get_unchecked ( index) , * f2. get_unchecked ( index) )
369- }
370-
371- /// Safe cast, but manually skip constructing unused fields.
372- #[ no_mangle]
373- pub fn inspect_manual_field0 ( slices : & [ & [ u8 ] ] , index : usize ) -> u64 {
374- let field0: & [ u64 ] = bytemuck:: try_cast_slice ( slices[ 0 ] ) . unwrap ( ) ;
375- field0[ index]
376- }
377-
378- /// Safe cast, manually access field 1 only.
379- #[ no_mangle]
380- pub fn inspect_manual_field1 ( slices : & [ & [ u8 ] ] , index : usize ) -> u64 {
381- let field1: & [ u64 ] = bytemuck:: try_cast_slice ( slices[ 1 ] ) . unwrap ( ) ;
382- field1[ index]
383- }
384-
385- /// The real pattern: from_byte_slices already done, container passed in, access .0[i].
386- /// This is what it looks like when you separate construction from access.
387- #[ no_mangle]
388- pub fn inspect_dotfield_0 ( container : ( & [ u64 ] , & [ u64 ] , & [ u64 ] ) , index : usize ) -> u64 {
389- container. 0 [ index]
390- }
391-
392- /// Same for field 1.
393- #[ no_mangle]
394- pub fn inspect_dotfield_1 ( container : ( & [ u64 ] , & [ u64 ] , & [ u64 ] ) , index : usize ) -> u64 {
395- container. 1 [ index]
396- }
397-
398- /// All three fields from pre-constructed container.
399- #[ no_mangle]
400- pub fn inspect_dotfield_all ( container : ( & [ u64 ] , & [ u64 ] , & [ u64 ] ) , index : usize ) -> ( u64 , u64 , u64 ) {
401- ( container. 0 [ index] , container. 1 [ index] , container. 2 [ index] )
402- }
403-
404- // Boss level: full pipeline from Indexed-encoded &[u64] store.
405- // Indexed::decode → from_bytes → .0[index]
406- type Triple < ' a > = ( & ' a [ u64 ] , & ' a [ u64 ] , & ' a [ u64 ] ) ;
407-
408- /// Full pipeline: decode store, from_bytes, access .0[index].
409- #[ no_mangle]
410- pub fn inspect_boss_field0 ( store : & [ u64 ] , index : usize ) -> u64 {
411- use crate :: FromBytes ;
412- let container = Triple :: from_bytes ( & mut super :: decode ( store) ) ;
413- container. 0 [ index]
414- }
415-
416- /// Full pipeline: decode store, from_byte_slices, access .0[index].
417- #[ no_mangle]
418- pub fn inspect_boss_slices_field0 ( store : & [ u64 ] , index : usize ) -> u64 {
419- use crate :: FromBytes ;
420- let slices: Vec < & [ u8 ] > = super :: decode ( store) . collect ( ) ;
421- let container = Triple :: from_byte_slices ( & slices) ;
422- container. 0 [ index]
423- }
424-
425- /// Full pipeline via decode_index: just the first slice, field 0.
426- #[ no_mangle]
427- pub fn inspect_boss_decode_index_field0 ( store : & [ u64 ] , index : usize ) -> u64 {
428- let field0: & [ u64 ] = bytemuck:: try_cast_slice ( super :: decode_index ( store, 0 ) ) . unwrap ( ) ;
429- field0[ index]
430- }
431- }
432-
433269 #[ cfg( test) ]
434270 mod test {
435271
0 commit comments