azos icon indicating copy to clipboard operation
azos copied to clipboard

BixReader.ReadFromStream - if the source is MemoryStream use block copy for performance

Open itadapter opened this issue 1 year ago • 0 comments

Test for memoryStream and use blockcopy instead

[MethodImpl(MethodImplOptions.AggressiveInlining)]
    public void ReadFromStream(byte[] buffer, int count)
    {
      if (count <= 0) return;
      var total = 0;
      do
      {
        var got = m_Stream.Read(buffer, total, count - total);

        if (got < 1) //EOF
          throw new BixException(StringConsts.BIX_STREAM_CORRUPTED_ERROR + "ReadFromStream(Need: {0}; Got: {1})".Args(count, total));

        total += got;
      } while (total < count);
    }

itadapter avatar Jan 26 '23 17:01 itadapter