From 0a294abdcff0281da1ad8eeb450b4e812030b269 Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Fri, 4 Jan 2019 04:34:39 +0300 Subject: [PATCH] Eliminate some bounds checks in Path (#21721) --- src/System.Private.CoreLib/shared/System/IO/Path.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/System.Private.CoreLib/shared/System/IO/Path.cs b/src/System.Private.CoreLib/shared/System/IO/Path.cs index 364b847..3c9fc3e 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]; } /// -- 2.7.4