Microoptimization + code cleanup

performance-simd-rust
Inga 🏳‍🌈 7 years ago
parent e021ebbe27
commit 97d73e54af
  1. 11
      WhiteRabbit/Phrase.cs
  2. 2
      WhiteRabbit/StringsProcessor.cs

@ -2,8 +2,6 @@
{
internal unsafe struct Phrase
{
private const byte SPACE = 32;
public fixed byte Buffer[32];
public Phrase(byte[][] words, int numberOfCharacters)
@ -20,16 +18,13 @@
{
if (j >= currentWord.Length)
{
*currentPointer = SPACE;
j = 0;
wordIndex++;
currentWord = words[wordIndex];
}
else
{
*currentPointer = currentWord[j];
j++;
}
*currentPointer = currentWord[j];
j++;
}
bufferPointer[31] = (byte)length;

@ -17,7 +17,7 @@
// Dictionary of vectors to array of words represented by this vector
var vectorsToWords = words
.Where(word => word != null && word.Length > 0)
.Select(word => new { word, vector = this.VectorsConverter.GetVector(word) })
.Select(word => new { word = word.Concat(new byte[] { SPACE }).ToArray(), vector = this.VectorsConverter.GetVector(word) })
.Where(tuple => tuple.vector != null)
.Select(tuple => new { tuple.word, vector = tuple.vector.Value })
.GroupBy(tuple => tuple.vector)

Loading…
Cancel
Save