Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit b173b4b

Browse files
committed
Simplify loop in HashAlgorithm.ComputeHash
1 parent 8d8d3bc commit b173b4b

File tree

1 file changed

+3
-7
lines changed
  • src/System.Security.Cryptography.Hashing/src/System/Security/Cryptography

1 file changed

+3
-7
lines changed

src/System.Security.Cryptography.Hashing/src/System/Security/Cryptography/HashAlgorithm.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,10 @@ public byte[] ComputeHash(Stream inputStream)
5858
// Default the buffer size to 4K.
5959
byte[] buffer = new byte[4096];
6060
int bytesRead;
61-
do
61+
while ((bytesRead = inputStream.Read(buffer, 0, buffer.Length)) > 0)
6262
{
63-
bytesRead = inputStream.Read(buffer, 0, 4096);
64-
if (bytesRead > 0)
65-
{
66-
HashCore(buffer, 0, bytesRead);
67-
}
68-
} while (bytesRead > 0);
63+
HashCore(buffer, 0, bytesRead);
64+
}
6965
return CaptureHashCodeAndReinitialize();
7066
}
7167

0 commit comments

Comments
 (0)