Skip to content

Commit 5c2b21b

Browse files
Use 'AsSpan' over 'Substring' in 'System.Private.Xml' (#48277)
* Fix violation in System.Private.Xml - Prefer 'AsSpan' over 'Substring' when span-based overloads are available. * Update src/libraries/System.Private.Xml/src/System/Xml/Serialization/CodeIdentifier.cs Apply suggested optimization. Co-authored-by: Stephen Toub <[email protected]> Co-authored-by: Stephen Toub <[email protected]>
1 parent a62ca2d commit 5c2b21b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libraries/System.Private.Xml/src/System/Xml/Serialization/CodeIdentifier.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ private static void EscapeKeywords(string identifier, StringBuilder sb)
283283
{
284284
if (separator >= 0)
285285
{
286-
sb.Append(originalIdentifier.Substring(separator, 1));
286+
sb.Append(originalIdentifier[separator]);
287287
}
288288
separator++;
289289
separator += names[i].Length;

0 commit comments

Comments
 (0)