@@ -151,7 +151,7 @@ public unsafe static OperationStatus DecodeFromBase64Scalar(ReadOnlySpan<byte> s
151151 if ( MatchSystem ( Endianness . BIG ) )
152152 {
153153 triple <<= 8 ;
154- Marshal . Copy ( BitConverter . GetBytes ( triple ) , 0 , ( IntPtr ) dst , 2 ) ;
154+ Buffer . MemoryCopy ( & triple , dst , 2 , 2 ) ;
155155 }
156156 else
157157 {
@@ -180,7 +180,7 @@ public unsafe static OperationStatus DecodeFromBase64Scalar(ReadOnlySpan<byte> s
180180 if ( MatchSystem ( Endianness . BIG ) )
181181 {
182182 triple <<= 8 ;
183- Marshal . Copy ( BitConverter . GetBytes ( triple ) , 0 , ( IntPtr ) dst , 3 ) ;
183+ Buffer . MemoryCopy ( & triple , dst , 3 , 3 ) ;
184184 }
185185 else
186186 {
@@ -300,7 +300,7 @@ public unsafe static OperationStatus DecodeFromBase64Scalar(ReadOnlySpan<char> s
300300 if ( MatchSystem ( Endianness . BIG ) )
301301 {
302302 triple <<= 8 ;
303- Marshal . Copy ( BitConverter . GetBytes ( triple ) , 0 , ( IntPtr ) dst , 2 ) ;
303+ Buffer . MemoryCopy ( & triple , dst , 2 , 2 ) ;
304304 }
305305 else
306306 {
@@ -329,7 +329,7 @@ public unsafe static OperationStatus DecodeFromBase64Scalar(ReadOnlySpan<char> s
329329 if ( MatchSystem ( Endianness . BIG ) )
330330 {
331331 triple <<= 8 ;
332- Marshal . Copy ( BitConverter . GetBytes ( triple ) , 0 , ( IntPtr ) dst , 3 ) ;
332+ Buffer . MemoryCopy ( & triple , dst , 3 , 3 ) ;
333333 }
334334 else
335335 {
@@ -457,7 +457,7 @@ public unsafe static OperationStatus SafeDecodeFromBase64Scalar(ReadOnlySpan<byt
457457 if ( MatchSystem ( Endianness . BIG ) )
458458 {
459459 triple <<= 8 ;
460- Marshal . Copy ( BitConverter . GetBytes ( triple ) , 0 , ( IntPtr ) dst , 2 ) ;
460+ Buffer . MemoryCopy ( & triple , dst , 2 , 2 ) ;
461461 }
462462 else
463463 {
@@ -492,7 +492,7 @@ public unsafe static OperationStatus SafeDecodeFromBase64Scalar(ReadOnlySpan<byt
492492 if ( MatchSystem ( Endianness . BIG ) )
493493 {
494494 triple <<= 8 ;
495- Marshal . Copy ( BitConverter . GetBytes ( triple ) , 0 , ( IntPtr ) dst , 3 ) ;
495+ Buffer . MemoryCopy ( & triple , dst , 3 , 3 ) ;
496496 }
497497 else
498498 {
@@ -548,7 +548,6 @@ public unsafe static OperationStatus SafeDecodeFromBase64Scalar(ReadOnlySpan<cha
548548 return OperationStatus . DestinationTooSmall ;
549549 }
550550 Buffer . MemoryCopy ( bufferPtr , dst , 3 , 3 ) ;
551- //Marshal.Copy(buffer, 0, (IntPtr)dst, 3); // optimization opportunity: copy 4 bytes
552551 dst += 3 ;
553552 src += 4 ;
554553 }
@@ -621,7 +620,7 @@ public unsafe static OperationStatus SafeDecodeFromBase64Scalar(ReadOnlySpan<cha
621620 if ( MatchSystem ( Endianness . BIG ) )
622621 {
623622 triple <<= 8 ;
624- Marshal . Copy ( BitConverter . GetBytes ( triple ) , 0 , ( IntPtr ) dst , 2 ) ;
623+ Buffer . MemoryCopy ( & triple , dst , 2 , 2 ) ;
625624 }
626625 else
627626 {
@@ -656,7 +655,7 @@ public unsafe static OperationStatus SafeDecodeFromBase64Scalar(ReadOnlySpan<cha
656655 if ( MatchSystem ( Endianness . BIG ) )
657656 {
658657 triple <<= 8 ;
659- Marshal . Copy ( BitConverter . GetBytes ( triple ) , 0 , ( IntPtr ) dst , 3 ) ;
658+ Buffer . MemoryCopy ( & triple , dst , 3 , 3 ) ;
660659 }
661660 else
662661 {
0 commit comments