<commit_before>using System.Buffers;
using System.Threading;
using System.Threading.Tasks;

namespace System.IO
{
	public static class StreamExtensions
	{
		public static async Task<int> ReadByteAsync(this Stream stream, CancellationToken ctsToken = default)
		{
			ArrayPool<byte> pool = ArrayPool<byte>.Shared;
			byte[] buffer = pool.Rent(1);
			try
			{
				int len = await stream.ReadAsync(buffer.AsMemory(0, 1), ctsToken).ConfigureAwait(false);

				// End of stream.
				if (len == 0)
				{
					return -1;
				}

				return buffer[0];
			}
			finally
			{
				pool.Return(buffer);
			}
		}

		/// <summary>
		/// Attempts to read <paramref name="count"/> bytes from <paramref name="stream"/>.
		/// </summary>
		/// <param name="stream">Stream to read from.</param>
		/// <param name="buffer">Buffer whose length must be at least <paramref name="count"/> elements.</param>
		/// <param name="count">Number of bytes to read.</param>
		/// <param name="cancellationToken">Cancellation token to cancel the asynchronous operation.</param>
		/// <returns><paramref name="count"/> when all <paramref name="count"/> bytes were read from the stream. Otherwise, a number of remaining bytes that were not transmitted.</returns>
		public static async Task<int> ReadBlockAsync(this Stream stream, byte[] buffer, int count, CancellationToken cancellationToken = default)
		{
			int left = count;
			while (left != 0)
			{
				int read = await stream.ReadAsync(buffer.AsMemory(count - left, left), cancellationToken).ConfigureAwait(false);

				// End of stream.
				if (read == 0)
				{
					break;
				}

				left -= read;
			}
			return count - left;
		}
	}
}
<commit_msg>Fix documentation 2.<commit_after>using System.Buffers;
using System.Threading;
using System.Threading.Tasks;

namespace System.IO
{
	public static class StreamExtensions
	{
		public static async Task<int> ReadByteAsync(this Stream stream, CancellationToken ctsToken = default)
		{
			ArrayPool<byte> pool = ArrayPool<byte>.Shared;
			byte[] buffer = pool.Rent(1);
			try
			{
				int len = await stream.ReadAsync(buffer.AsMemory(0, 1), ctsToken).ConfigureAwait(false);

				// End of stream.
				if (len == 0)
				{
					return -1;
				}

				return buffer[0];
			}
			finally
			{
				pool.Return(buffer);
			}
		}

		/// <summary>
		/// Attempts to read <paramref name="count"/> bytes from <paramref name="stream"/>.
		/// </summary>
		/// <param name="stream">Stream to read from.</param>
		/// <param name="buffer">Buffer whose length must be at least <paramref name="count"/> elements.</param>
		/// <param name="count">Number of bytes to read.</param>
		/// <param name="cancellationToken">Cancellation token to cancel the asynchronous operation.</param>
		/// <returns>Number of read bytes. At most <paramref name="count"/>.</returns>
		public static async Task<int> ReadBlockAsync(this Stream stream, byte[] buffer, int count, CancellationToken cancellationToken = default)
		{
			int left = count;
			while (left != 0)
			{
				int read = await stream.ReadAsync(buffer.AsMemory(count - left, left), cancellationToken).ConfigureAwait(false);

				// End of stream.
				if (read == 0)
				{
					break;
				}

				left -= read;
			}
			return count - left;
		}
	}
}

{'fraction_non_alphanumeric': 0.13691026827012026, 'fraction_numerical': 0.005242059821153253, 'mean_word_length': 3.175032175032175, 'pattern_counts': {'":': 0, '<': 44, '<?xml version=': 0, '>': 44, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '122101', 'n_tokens_mistral': 1168, 'n_tokens_neox': 983, 'n_words': 286}