@@ -967,30 +967,28 @@ macro_rules! glib_object_wrapper {
967967
968968 #[ doc( hidden) ]
969969 impl <' a $( , $( $generic $( : $bound $( + $bound2) * ) ?) ,+) ?> $crate:: translate:: ToGlibContainerFromSlice <' a, * mut * mut $ffi_name> for $name $( <$( $generic) ,+>) ? {
970- type Storage = ( Vec <$crate :: translate :: Stash < ' a , * mut $ffi_name , Self > >, Option <Vec <* mut $ffi_name>>) ;
970+ type Storage = ( std :: marker :: PhantomData < & ' a [ Self ] >, Option <Vec <* mut $ffi_name>>) ;
971971
972972 fn to_glib_none_from_slice( t: & ' a [ Self ] ) -> ( * mut * mut $ffi_name, Self :: Storage ) {
973- let v : Vec <_> = t . iter ( ) . map ( |s| $crate :: translate :: ToGlibPtr :: to_glib_none ( s ) ) . collect ( ) ;
974- let mut v_ptr: Vec <_> = v . iter( ) . map( |s| s . 0 ) . collect ( ) ;
975- v_ptr. push( std:: ptr:: null_mut( ) as * mut $ffi_name ) ;
973+ let mut v_ptr = Vec :: with_capacity ( t . len ( ) + 1 ) ;
974+ v_ptr. extend ( t . iter( ) . map( |t| < Self as $crate :: ObjectType > :: as_ptr ( t ) ) ) ;
975+ v_ptr. push( std:: ptr:: null_mut( ) ) ;
976976
977- ( v_ptr. as_ptr( ) as * mut * mut $ffi_name, ( v , Some ( v_ptr) ) )
977+ ( v_ptr. as_ptr( ) as * mut * mut $ffi_name, ( std :: marker :: PhantomData , Some ( v_ptr) ) )
978978 }
979979
980980 fn to_glib_container_from_slice( t: & ' a [ Self ] ) -> ( * mut * mut $ffi_name, Self :: Storage ) {
981- let v: Vec <_> = t. iter( ) . map( |s| $crate:: translate:: ToGlibPtr :: to_glib_none( s) ) . collect( ) ;
982-
983981 let v_ptr = unsafe {
984982 let v_ptr = $crate:: ffi:: g_malloc0( std:: mem:: size_of:: <* mut $ffi_name>( ) * ( t. len( ) + 1 ) ) as * mut * mut $ffi_name;
985983
986- for ( i, s ) in v . iter( ) . enumerate( ) {
987- std:: ptr:: write( v_ptr. add( i) , s . 0 ) ;
984+ for ( i, t ) in t . iter( ) . enumerate( ) {
985+ std:: ptr:: write( v_ptr. add( i) , < Self as $crate :: ObjectType > :: as_ptr ( t ) ) ;
988986 }
989987
990988 v_ptr
991989 } ;
992990
993- ( v_ptr, ( v , None ) )
991+ ( v_ptr, ( std :: marker :: PhantomData , None ) )
994992 }
995993
996994 fn to_glib_full_from_slice( t: & [ Self ] ) -> * mut * mut $ffi_name {
@@ -1008,7 +1006,7 @@ macro_rules! glib_object_wrapper {
10081006
10091007 #[ doc( hidden) ]
10101008 impl <' a $( , $( $generic $( : $bound $( + $bound2) * ) ?) ,+) ?> $crate:: translate:: ToGlibContainerFromSlice <' a, * const * mut $ffi_name> for $name $( <$( $generic) ,+>) ? {
1011- type Storage = ( Vec <$crate :: translate :: Stash < ' a , * mut $ffi_name , Self > >, Option <Vec <* mut $ffi_name>>) ;
1009+ type Storage = ( std :: marker :: PhantomData < & ' a [ Self ] >, Option <Vec <* mut $ffi_name>>) ;
10121010
10131011 fn to_glib_none_from_slice( t: & ' a [ Self ] ) -> ( * const * mut $ffi_name, Self :: Storage ) {
10141012 let ( ptr, stash) = $crate:: translate:: ToGlibContainerFromSlice :: <' a, * mut * mut $ffi_name>:: to_glib_none_from_slice( t) ;
0 commit comments