Local function replaced with Lambda for readability in RecyclableList.DoIndexOfParallel.
This commit is contained in:
1 parent
948156b897
commit
b038bcfdc9
1 file changed
+9
-36
@@ -287,42 +287,7 @@ namespace Recyclable.Collections
|
|||||||
Exception? ex = null;
|
Exception? ex = null;
|
||||||
|
|
||||||
// (long)(_longCount * 0.329) => most efficient step, based on benchmarks
|
// (long)(_longCount * 0.329) => most efficient step, based on benchmarks
|
||||||
ItemRangesIterator.Iterate(0, _blockSize, _blockSizePow2BitShift, _longCount, _longCountIndexOfStep, LocalIndexOf);
|
ItemRangesIterator.Iterate(0, _blockSize, _blockSizePow2BitShift, _longCount, _longCountIndexOfStep, itemRange =>
|
||||||
allDoneSignal.SignalAndWait();
|
|
||||||
if (ex == null)
|
|
||||||
{
|
|
||||||
return foundItemIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
ex.CaptureAndRethrow();
|
|
||||||
return ItemNotFoundIndexLong;
|
|
||||||
|
|
||||||
//int blockIndex = 0;
|
|
||||||
//int itemIndex = 0;
|
|
||||||
//long itemsCount = _longCount;
|
|
||||||
//while (itemsCount > step)
|
|
||||||
//{
|
|
||||||
// if (!LocalIndexOf(new(blockIndex, itemIndex, step)))
|
|
||||||
// {
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// itemsCount -= step;
|
|
||||||
// //blockIndex = (int)Math.DivRem(itemIndex + step, blockSize, out itemIndex);
|
|
||||||
// blockIndex += (int)((itemIndex + step) >> _blockSizePow2BitShift);
|
|
||||||
// itemIndex = (int)((itemIndex + step) & _blockSizeMinus1);
|
|
||||||
// //itemIndex += step;
|
|
||||||
// //while (itemIndex >= blockSize)
|
|
||||||
// //{
|
|
||||||
// // blockIndex++;
|
|
||||||
// // itemIndex -= blockSize;
|
|
||||||
// //}
|
|
||||||
//}
|
|
||||||
|
|
||||||
//_ = LocalIndexOf(new(blockIndex, itemIndex, itemsCount));
|
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
bool LocalIndexOf(ItemRange itemRange)
|
|
||||||
{
|
{
|
||||||
_ = allDoneSignal.AddParticipant();
|
_ = allDoneSignal.AddParticipant();
|
||||||
_ = Task.Factory.StartNew(() =>
|
_ = Task.Factory.StartNew(() =>
|
||||||
@@ -362,7 +327,15 @@ namespace Recyclable.Collections
|
|||||||
//});
|
//});
|
||||||
|
|
||||||
return !itemFoundSignal.IsSet;
|
return !itemFoundSignal.IsSet;
|
||||||
|
});
|
||||||
|
allDoneSignal.SignalAndWait();
|
||||||
|
if (ex == null)
|
||||||
|
{
|
||||||
|
return foundItemIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ex.CaptureAndRethrow();
|
||||||
|
return ItemNotFoundIndexLong;
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
|
||||||
|
|||||||
Reference in new issue
Block a user