Skip to content

Commit a751f5c

Browse files
authored
reorder (#300)
1 parent 353880f commit a751f5c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

BitFaster.Caching/Lfu/CmSketch.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ private unsafe int EstimateFrequencyAvx(T value)
241241
Vector128<int> blockOffset = Avx2.Add(Vector128.Create(block), offset); // i - table index
242242
blockOffset = Avx2.Add(blockOffset, Vector128.Create(0, 2, 4, 6)); // + (i << 1)
243243

244-
fixed (long* tablePtr = &table[0])
244+
fixed (long* tablePtr = table)
245245
{
246246
Vector256<long> tableVector = Avx2.GatherVector256(tablePtr, blockOffset, 8);
247247
index = Avx2.ShiftLeftLogical(index, 2);
@@ -284,7 +284,7 @@ private unsafe void IncrementAvx(T value)
284284
Vector128<int> blockOffset = Avx2.Add(Vector128.Create(block), offset); // i - table index
285285
blockOffset = Avx2.Add(blockOffset, Vector128.Create(0, 2, 4, 6)); // + (i << 1)
286286

287-
fixed (long* tablePtr = &table[0])
287+
fixed (long* tablePtr = table)
288288
{
289289
Vector256<long> tableVector = Avx2.GatherVector256(tablePtr, blockOffset, 8);
290290

@@ -309,20 +309,20 @@ private unsafe void IncrementAvx(T value)
309309
// Mask to zero out non matches (add zero below) - first operand is NOT then AND result (order matters)
310310
inc = Avx2.AndNot(masked, inc);
311311

312+
Vector256<byte> result = Avx2.CompareEqual(masked.AsByte(), Vector256<byte>.Zero);
313+
bool wasInc = Avx2.MoveMask(result.AsByte()) == unchecked((int)(0b1111_1111_1111_1111_1111_1111_1111_1111));
314+
312315
tablePtr[blockOffset.GetElement(0)] += inc.GetElement(0);
313316
tablePtr[blockOffset.GetElement(1)] += inc.GetElement(1);
314317
tablePtr[blockOffset.GetElement(2)] += inc.GetElement(2);
315318
tablePtr[blockOffset.GetElement(3)] += inc.GetElement(3);
316319

317-
Vector256<byte> result = Avx2.CompareEqual(masked.AsByte(), Vector256<byte>.Zero);
318-
bool wasInc = Avx2.MoveMask(result.AsByte()) == unchecked((int)(0b1111_1111_1111_1111_1111_1111_1111_1111));
319-
320320
if (wasInc && (++size == sampleSize))
321321
{
322322
Reset();
323323
}
324324
}
325325
}
326326
#endif
327-
}
327+
}
328328
}

0 commit comments

Comments
 (0)