CopyFrom() public method

public CopyFrom ( int alreadyCopied, byte segmentBuffer, int indexInSegment, int bytesToRead ) : void
alreadyCopied int
segmentBuffer byte
indexInSegment int
bytesToRead int
return void
コード例 #1
0
        private int ReadImpl(ref ByteSlice slice)
        {
            if (_position >= _length)
            {
                return(0);
            }

            var alreadyCopied = 0;
            var toCopy        = Math.Min(slice.Count, _length - _position);

            while (toCopy > 0)
            {
                var index          = Calculator.GetSegmentIndex(_position);
                var indexInSegment = Calculator.GetIndexInSegment(_position);

                var segment = FindSegment(index);

                var bytesToRead = Math.Min(segment->Length - indexInSegment, toCopy);
                if (bytesToRead > 0)
                {
                    var segmentBuffer = segment->Buffer;
                    slice.CopyFrom(alreadyCopied, segmentBuffer, indexInSegment, bytesToRead);
                    alreadyCopied += bytesToRead;
                    toCopy        -= bytesToRead;
                    _position     += bytesToRead;
                }
            }

            return(alreadyCopied);
        }
コード例 #2
0
        private int ReadImpl(ref ByteSlice slice)
        {
            if (_position >= _length)
                return 0;

            var alreadyCopied = 0;
            var toCopy = Math.Min(slice.Count, _length - _position);
            while (toCopy > 0)
            {
                var index = Calculator.GetSegmentIndex(_position);
                var indexInSegment = Calculator.GetIndexInSegment(_position);

                var segment = FindSegment(index);

                var bytesToRead = Math.Min(segment->Length - indexInSegment, toCopy);
                if (bytesToRead > 0)
                {
                    var segmentBuffer = segment->Buffer;
                    slice.CopyFrom(alreadyCopied, segmentBuffer, indexInSegment, bytesToRead);
                    alreadyCopied += bytesToRead;
                    toCopy -= bytesToRead;
                    _position += bytesToRead;
                }
            }

            return alreadyCopied;
        }