From 106eebda0f91acb4354a3a83b5be5d70343f92f6 Mon Sep 17 00:00:00 2001 From: Miha Zupan Date: Tue, 18 Feb 2020 18:36:49 +0100 Subject: [PATCH] Simplify CheckIsReserved in IriHelper (#32340) * Simplify CheckIsReserved in IriHelper * Simplify CheckIsReserved further --- .../System.Private.Uri/src/System/IriHelper.cs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/libraries/System.Private.Uri/src/System/IriHelper.cs b/src/libraries/System.Private.Uri/src/System/IriHelper.cs index 9f6ec186d915fb..5d8278cd06e9bd 100644 --- a/src/libraries/System.Private.Uri/src/System/IriHelper.cs +++ b/src/libraries/System.Private.Uri/src/System/IriHelper.cs @@ -53,19 +53,12 @@ internal static bool CheckIriUnicodeRange(char highSurr, char lowSurr, out bool // internal static bool CheckIsReserved(char ch, UriComponents component) { - if ((component != UriComponents.Scheme) && - (component != UriComponents.UserInfo) && - (component != UriComponents.Host) && - (component != UriComponents.Port) && - (component != UriComponents.Path) && - (component != UriComponents.Query) && - (component != UriComponents.Fragment) - ) + if ((UriComponents.AbsoluteUri & component) == 0) { - return (component == (UriComponents)0) ? UriHelper.IsGenDelim(ch) : false; + return component == 0 && UriHelper.IsGenDelim(ch); } - return UriHelper.RFC3986ReservedMarks.IndexOf(ch) >= 0; + return UriHelper.RFC3986ReservedMarks.Contains(ch); } //