summaryrefslogtreecommitdiff
path: root/src/System.Private.CoreLib/shared/System
diff options
context:
space:
mode:
authorEgor Bogatov <egorbo@gmail.com>2019-01-04 04:34:39 +0300
committerJan Kotas <jkotas@microsoft.com>2019-01-03 15:34:39 -1000
commit0a294abdcff0281da1ad8eeb450b4e812030b269 (patch)
tree5e4365ef11e004b73cfa5fff8954c1360ce95758 /src/System.Private.CoreLib/shared/System
parent8d2f4ed72a9d48164a4c8147fe7911e62a5d9594 (diff)
downloadcoreclr-0a294abdcff0281da1ad8eeb450b4e812030b269.tar.gz
coreclr-0a294abdcff0281da1ad8eeb450b4e812030b269.tar.bz2
coreclr-0a294abdcff0281da1ad8eeb450b4e812030b269.zip
Eliminate some bounds checks in Path (#21721)
Diffstat (limited to 'src/System.Private.CoreLib/shared/System')
-rw-r--r--src/System.Private.CoreLib/shared/System/IO/Path.cs4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/System.Private.CoreLib/shared/System/IO/Path.cs b/src/System.Private.CoreLib/shared/System/IO/Path.cs
index 364b8472cf..3c9fc3ed24 100644
--- a/src/System.Private.CoreLib/shared/System/IO/Path.cs
+++ b/src/System.Private.CoreLib/shared/System/IO/Path.cs
@@ -673,6 +673,9 @@ namespace System.IO
byte b3 = bytes[3];
byte b4 = bytes[4];
+ // write to chars[11] first in order to eliminate redundant bounds checks
+ chars[11] = (char)Base32Char[bytes[7] & 0x1F];
+
// Consume the 5 Least significant bits of the first 5 bytes
chars[0] = (char)Base32Char[b0 & 0x1F];
chars[1] = (char)Base32Char[b1 & 0x1F];
@@ -707,7 +710,6 @@ namespace System.IO
// Consume the 5 Least significant bits of the remaining 3 bytes
chars[9] = (char)Base32Char[bytes[5] & 0x1F];
chars[10] = (char)Base32Char[bytes[6] & 0x1F];
- chars[11] = (char)Base32Char[bytes[7] & 0x1F];
}
/// <summary>