Compare commits

...

1 Commits

  1. 17
      dotnet/WhiteRabbit/PhraseSet.cs

@ -15,22 +15,23 @@
{ {
var permutation = permutations[offset + i]; var permutation = permutations[offset + i];
var startPointer = bufferPointer + i * 8; var startPointer = bufferPointer + i * 8;
byte[] currentWord = words[permutation[0]]; byte[] currentWord;
var j = 0; var j = 0;
var wordIndex = 0; var wordIndex = 0;
var currentPointer = (byte*)startPointer; var currentPointer = (byte*)startPointer;
byte* lastPointer = currentPointer + length; byte* lastPointer = currentPointer + length;
for (; currentPointer < lastPointer; currentPointer++) for (; currentPointer < lastPointer; currentPointer++)
{ {
if (j >= currentWord.Length) currentWord = words[permutation[wordIndex]];
{
j = 0;
wordIndex++;
currentWord = words[permutation[wordIndex]];
}
*currentPointer = currentWord[j]; *currentPointer = currentWord[j];
j++; j++;
// 0xffffffff if greater than or equal, 0 if less than
var comparisonResult = unchecked((int)((((uint)j - (uint)currentWord.Length) >> 31) - 1));
j = (comparisonResult & 0) | (~comparisonResult & j);
wordIndex = (comparisonResult & (wordIndex + 1)) | (~comparisonResult & wordIndex);
} }
*currentPointer = 128; *currentPointer = 128;

Loading…
Cancel
Save