PhraseSet filling moved out to separate method

master
Inga 🏳‍🌈 8 years ago
parent cbb7ccb59b
commit a154b211a5
  1. 17
      dotnet/WhiteRabbit/PhraseSet.cs

@ -15,11 +15,20 @@
fixed (long* bufferPointer = this.Buffer) fixed (long* bufferPointer = this.Buffer)
{ {
long* longBuffer = (long*)bufferPointer;
int numberOfWords = wordIndexes.Length;
fixed (ulong* permutationsPointer = permutations) fixed (ulong* permutationsPointer = permutations)
{ {
fixed (int* wordIndexesPointer = wordIndexes)
{
FillPhraseSet(bufferPointer, allWords, wordIndexesPointer, permutationsPointer, permutationOffset, numberOfCharacters, wordIndexes.Length);
}
}
}
}
private static unsafe void FillPhraseSet(long* bufferPointer, Word[] allWords, int* wordIndexes, ulong* permutationsPointer, int permutationOffset, int numberOfCharacters, int numberOfWords)
{
long* longBuffer = (long*)bufferPointer;
var currentPermutationPointer = permutationsPointer + permutationOffset; var currentPermutationPointer = permutationsPointer + permutationOffset;
for (var i = 0; i < Constants.PhrasesPerSet; i++, currentPermutationPointer++) for (var i = 0; i < Constants.PhrasesPerSet; i++, currentPermutationPointer++)
{ {
@ -43,7 +52,6 @@
longBuffer += 4; longBuffer += 4;
} }
}
var length = numberOfCharacters + numberOfWords - 1; var length = numberOfCharacters + numberOfWords - 1;
byte* byteBuffer = ((byte*)bufferPointer) + length; byte* byteBuffer = ((byte*)bufferPointer) + length;
@ -61,7 +69,6 @@
uintBuffer += 8; uintBuffer += 8;
} }
} }
}
public unsafe byte[] GetBytes(int number) public unsafe byte[] GetBytes(int number)
{ {

Loading…
Cancel
Save