SHARE
TWEET

Untitled

a guest May 12th, 2012 57 Never
  1. private static unsafe void MaskArrayAsLongs(int mask, int[] ints)
  2. {
  3.     var longMask = ((long)mask << 32) + mask;
  4.  
  5.     fixed (int* pt = ints)
  6.     {
  7.         var end = (long*)pt + ints.Length / 2;
  8.  
  9.         if (ints.Length % 2 == 1)
  10.         {
  11.             ints[ints.Length - 1] ^= mask;
  12.         }
  13.  
  14.         for (var curr = (long*)pt; curr < end; curr++)
  15.         {
  16.             *curr ^= longMask;
  17.         }
  18.     }
  19. }
RAW Paste Data
Top