diff --git a/dotnet/WhiteRabbit/PhraseSet.cs b/dotnet/WhiteRabbit/PhraseSet.cs index e0a47c5..7c8dab8 100644 --- a/dotnet/WhiteRabbit/PhraseSet.cs +++ b/dotnet/WhiteRabbit/PhraseSet.cs @@ -10,21 +10,18 @@ { private uint[] Buffer; - public int Length; - - public PhraseSet(int length) + public void Init() { - this.Length = length; - this.Buffer = new uint[8 * length]; + this.Buffer = new uint[8 * Constants.PhrasesPerSet]; } - public unsafe void InitPhraseSet(int numberOfCharacters, int numberOfWords) + public unsafe void FillLength(int numberOfCharacters, int numberOfWords) { fixed (uint* bufferPointer = this.Buffer) { var length = (uint)(numberOfCharacters + numberOfWords - 1); var lengthInBits = (uint)(length << 3); - for (var i = 0; i < this.Length; i++) + for (var i = 0; i < Constants.PhrasesPerSet; i++) { bufferPointer[7 + i * 8] = lengthInBits; ((byte*)bufferPointer)[length + i * 32] = 128 ^ ' '; @@ -71,7 +68,7 @@ public unsafe byte[] GetBytes(int number) { - Debug.Assert(number < this.Length); + Debug.Assert(number < Constants.PhrasesPerSet); fixed (uint* bufferPointer = this.Buffer) { @@ -98,7 +95,7 @@ public unsafe string DebugBytes(int number) { - Debug.Assert(number < this.Length); + Debug.Assert(number < Constants.PhrasesPerSet); fixed (uint* bufferPointer = this.Buffer) { diff --git a/dotnet/WhiteRabbit/Program.cs b/dotnet/WhiteRabbit/Program.cs index 0ebed3a..4b9485d 100644 --- a/dotnet/WhiteRabbit/Program.cs +++ b/dotnet/WhiteRabbit/Program.cs @@ -86,7 +86,7 @@ private static void ProcessPhraseSet(PhraseSet phraseSet, Vector expectedHashesFirstComponents, Stopwatch stopwatch) { phraseSet.ComputeMD5(); - for (var i = 0; i < phraseSet.Length; i++) + for (var i = 0; i < Constants.PhrasesPerSet; i++) { /*Debug.Assert( sourceChars == ToOrderedChars(ToString(phraseSet, i)), diff --git a/dotnet/WhiteRabbit/StringsProcessor.cs b/dotnet/WhiteRabbit/StringsProcessor.cs index 45fa83c..1dfcf8d 100644 --- a/dotnet/WhiteRabbit/StringsProcessor.cs +++ b/dotnet/WhiteRabbit/StringsProcessor.cs @@ -120,9 +120,11 @@ private void ProcessSum(int[] sum, Action action) { - var initialPhraseSet = new PhraseSet(Constants.PhrasesPerSet); - initialPhraseSet.InitPhraseSet(this.NumberOfCharacters, sum.Length); - var phraseSet = new PhraseSet(Constants.PhrasesPerSet); + var initialPhraseSet = new PhraseSet(); + initialPhraseSet.Init(); + initialPhraseSet.FillLength(this.NumberOfCharacters, sum.Length); + var phraseSet = new PhraseSet(); + phraseSet.Init(); var filter = ComputeFilter(sum); var wordsVariants = this.ConvertVectorsToWordIndexes(sum); foreach (var wordsArray in Flattener.Flatten(wordsVariants))