@@ -130,8 +130,7 @@ private static Exception ConvertOrWidenPrimitivesEnumsAndPointersIfPossible(obje
130
130
EETypeElementType dstElementType = dstEEType ->ElementType ;
131
131
EETypeElementType srcElementType = srcEEType ->ElementType ;
132
132
133
- void * rawDstValue = null ;
134
-
133
+ bool boolValue ;
135
134
char charValue ;
136
135
sbyte sbyteValue ;
137
136
byte byteValue ;
@@ -144,8 +143,7 @@ private static Exception ConvertOrWidenPrimitivesEnumsAndPointersIfPossible(obje
144
143
float floatValue ;
145
144
double doubleValue ;
146
145
147
- Unsafe . SkipInit ( out dstObject ) ;
148
-
146
+ void * rawDstValue ;
149
147
ref byte rawSrcValue = ref RuntimeHelpers . GetRawData ( srcObject ) ;
150
148
151
149
switch ( dstElementType )
@@ -154,11 +152,12 @@ private static Exception ConvertOrWidenPrimitivesEnumsAndPointersIfPossible(obje
154
152
switch ( srcElementType )
155
153
{
156
154
case EETypeElementType . Boolean :
157
- dstObject = srcObject ;
155
+ boolValue = Unsafe . As < byte , bool > ( ref rawSrcValue ) ;
158
156
break ;
159
157
default :
160
158
goto Failure ;
161
159
}
160
+ rawDstValue = & boolValue ;
162
161
break ;
163
162
164
163
case EETypeElementType . Char :
@@ -429,13 +428,7 @@ private static Exception ConvertOrWidenPrimitivesEnumsAndPointersIfPossible(obje
429
428
goto Failure ;
430
429
}
431
430
432
- // The only case where 'rawDstValue' is not set is for bool values, which set 'dstObject'
433
- // directly. In all other cases, 'rawDstValue' is guaranteed to not be null.
434
- if ( rawDstValue != null )
435
- {
436
- dstObject = RuntimeImports . RhBox ( dstEEType , ref * ( byte * ) rawDstValue ) ;
437
- }
438
-
431
+ dstObject = RuntimeImports . RhBox ( dstEEType , ref * ( byte * ) rawDstValue ) ;
439
432
Debug. Assert ( dstObject . GetMethodTable ( ) == dstEEType ) ;
440
433
return null ;
441
434
0 commit comments