Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on May 12th, 2012  |  syntax: C#  |  size: 0.42 KB  |  views: 45  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }
clone this paste RAW Paste Data