@@ -3171,7 +3171,7 @@ private unsafe void ParseRemaining()
31713171 if ( buildIriStringFromPath )
31723172 {
31733173 DebugAssertInCtor ( ) ;
3174- _string += _originalUnicodeString . Substring ( origIdx ) ;
3174+ _string = string . Concat ( _string , _originalUnicodeString . AsSpan ( origIdx ) ) ;
31753175 }
31763176
31773177 string str = _string ;
@@ -3905,7 +3905,6 @@ private unsafe int CheckAuthorityHelper(char* pString, int idx, int length,
39053905 return idx;
39063906 }
39073907
3908- string? userInfoString = null ;
39093908 // Attempt to parse user info first
39103909
39113910 if ( ( syntaxFlags & UriSyntaxFlags . MayHaveUserInfo ) != 0 )
@@ -3923,23 +3922,15 @@ private unsafe int CheckAuthorityHelper(char* pString, int idx, int length,
39233922 flags |= Flags. HasUserInfo ;
39243923
39253924 // Iri'ze userinfo
3926- if ( iriParsing )
3925+ if ( iriParsing && hostNotUnicodeNormalized )
39273926 {
3928- if ( hostNotUnicodeNormalized )
3929- {
3930- // Normalize user info
3931- userInfoString = IriHelper. EscapeUnescapeIri ( pString , startInput , start + 1 , UriComponents . UserInfo ) ;
3932- newHost += userInfoString;
3927+ // Normalize user info
3928+ newHost += IriHelper. EscapeUnescapeIri ( pString , startInput , start + 1 , UriComponents . UserInfo ) ;
39333929
3934- if ( newHost . Length > ushort . MaxValue )
3935- {
3936- err = ParsingError. SizeLimit ;
3937- return idx;
3938- }
3939- }
3940- else
3930+ if ( newHost . Length > ushort . MaxValue )
39413931 {
3942- userInfoString = new string ( pString , startInput , start - startInput + 1 ) ;
3932+ err = ParsingError. SizeLimit ;
3933+ return idx;
39433934 }
39443935 }
39453936 ++ start;
@@ -3956,7 +3947,7 @@ private unsafe int CheckAuthorityHelper(char* pString, int idx, int length,
39563947
39573948 if ( hostNotUnicodeNormalized )
39583949 {
3959- newHost += new string ( pString , start , end - start ) ;
3950+ newHost = string . Concat ( newHost , new ReadOnlySpan < char > ( pString + start , end - start ) ) ;
39603951 flags |= Flags. HostUnicodeNormalized ;
39613952 justNormalized = true ;
39623953 }
@@ -3968,7 +3959,7 @@ private unsafe int CheckAuthorityHelper(char* pString, int idx, int length,
39683959
39693960 if ( hostNotUnicodeNormalized )
39703961 {
3971- newHost += new string ( pString , start , end - start ) ;
3962+ newHost = string . Concat ( newHost , new ReadOnlySpan < char > ( pString + start , end - start ) ) ;
39723963 flags |= Flags. HostUnicodeNormalized ;
39733964 justNormalized = true ;
39743965 }
@@ -4008,7 +3999,7 @@ private unsafe int CheckAuthorityHelper(char* pString, int idx, int length,
40083999 flags |= Flags . UncHostType ;
40094000 if ( hostNotUnicodeNormalized )
40104001 {
4011- newHost += new string ( pString , start , end - start ) ;
4002+ newHost = string . Concat ( newHost , new ReadOnlySpan < char > ( pString + start , end - start ) ) ;
40124003 flags |= Flags. HostUnicodeNormalized ;
40134004 justNormalized = true ;
40144005 }
@@ -4082,7 +4073,7 @@ private unsafe int CheckAuthorityHelper(char* pString, int idx, int length,
40824073
40834074 if ( hasUnicode && justNormalized )
40844075 {
4085- newHost += new string ( pString , startPort , idx - startPort ) ;
4076+ newHost = string . Concat ( newHost , new ReadOnlySpan < char > ( pString + startPort , idx - startPort ) ) ;
40864077 }
40874078 }
40884079 else
0 commit comments