@@ -359,13 +359,13 @@ private byte SetBit(byte curBitMap, int index, bool value)
359359 }
360360
361361 // private function. Faster to use when we already have a span since it avoids indexing
362- private void SetValidityBit ( Span < byte > bitMapBufferSpan , int index , bool value )
362+ private void SetValidityBit ( Span < byte > validitySpan , int index , bool value )
363363 {
364364 int bitMapBufferIndex = ( int ) ( ( uint ) index / 8 ) ;
365- Debug . Assert ( bitMapBufferSpan . Length >= bitMapBufferIndex ) ;
366- byte curBitMap = bitMapBufferSpan [ bitMapBufferIndex ] ;
365+ Debug . Assert ( validitySpan . Length >= bitMapBufferIndex ) ;
366+ byte curBitMap = validitySpan [ bitMapBufferIndex ] ;
367367 byte newBitMap = SetBit ( curBitMap , index , value ) ;
368- bitMapBufferSpan [ bitMapBufferIndex ] = newBitMap ;
368+ validitySpan [ bitMapBufferIndex ] = newBitMap ;
369369 }
370370
371371 /// <summary>
@@ -457,25 +457,25 @@ public T? this[long rowIndex]
457457 return null ;
458458 }
459459 int arrayIndex = GetArrayContainingRowIndex ( rowIndex ) ;
460- rowIndex = rowIndex - arrayIndex * ReadOnlyDataFrameBuffer < T > . MaxCapacity ;
461- return Buffers [ arrayIndex ] [ ( int ) rowIndex ] ;
460+ var bufferOffset = ( int ) ( rowIndex % ReadOnlyDataFrameBuffer < T > . MaxCapacity ) ;
461+ return Buffers [ arrayIndex ] [ bufferOffset ] ;
462462 }
463463 set
464464 {
465465 int arrayIndex = GetArrayContainingRowIndex ( rowIndex ) ;
466- rowIndex = rowIndex - arrayIndex * ReadOnlyDataFrameBuffer < T > . MaxCapacity ;
466+ var bufferOffset = ( int ) ( rowIndex % ReadOnlyDataFrameBuffer < T > . MaxCapacity ) ;
467467
468468 Buffers . GetOrCreateMutable ( arrayIndex ) ;
469469 NullBitMapBuffers . GetOrCreateMutable ( arrayIndex ) ;
470470
471471 if ( value . HasValue )
472472 {
473- Buffers [ arrayIndex ] [ ( int ) rowIndex ] = value . Value ;
473+ Buffers [ arrayIndex ] [ bufferOffset ] = value . Value ;
474474 SetValidityBit ( rowIndex , true ) ;
475475 }
476476 else
477477 {
478- Buffers [ arrayIndex ] [ ( int ) rowIndex ] = default ;
478+ Buffers [ arrayIndex ] [ bufferOffset ] = default ;
479479 SetValidityBit ( rowIndex , false ) ;
480480 }
481481 }
0 commit comments