@@ -52,11 +52,8 @@ public static class WebUtility
52
52
// characters need to be encoded.
53
53
// For larger string we rent the input string's length plus a fixed
54
54
// conservative amount of chars from the ArrayPool.
55
- Span < char > buffer = value . Length < 80 ?
56
- stackalloc char [ 256 ] :
57
- null ;
58
- ValueStringBuilder sb = buffer != null ?
59
- new ValueStringBuilder ( buffer ) :
55
+ ValueStringBuilder sb = value . Length < 80 ?
56
+ new ValueStringBuilder ( stackalloc char [ 256 ] ) :
60
57
new ValueStringBuilder ( value . Length + 200 ) ;
61
58
62
59
sb . Append ( valueSpan . Slice ( 0 , index ) ) ;
@@ -92,11 +89,8 @@ public static void HtmlEncode(string? value, TextWriter output)
92
89
// characters need to be encoded.
93
90
// For larger string we rent the input string's length plus a fixed
94
91
// conservative amount of chars from the ArrayPool.
95
- Span < char > buffer = value . Length < 80 ?
96
- stackalloc char [ 256 ] :
97
- null ;
98
- ValueStringBuilder sb = buffer != null ?
99
- new ValueStringBuilder ( buffer ) :
92
+ ValueStringBuilder sb = value . Length < 80 ?
93
+ new ValueStringBuilder ( stackalloc char [ 256 ] ) :
100
94
new ValueStringBuilder ( value . Length + 200 ) ;
101
95
102
96
sb . Append ( valueSpan . Slice ( 0 , index ) ) ;
@@ -201,11 +195,8 @@ private static void HtmlEncode(ReadOnlySpan<char> input, ref ValueStringBuilder
201
195
202
196
// In the worst case the decoded string has the same length.
203
197
// For small inputs we use stack allocation.
204
- Span < char > buffer = value . Length <= 256 ?
205
- stackalloc char [ 256 ] :
206
- null ;
207
- ValueStringBuilder sb = buffer != null ?
208
- new ValueStringBuilder ( buffer ) :
198
+ ValueStringBuilder sb = value . Length <= 256 ?
199
+ new ValueStringBuilder ( stackalloc char [ 256 ] ) :
209
200
new ValueStringBuilder ( value . Length ) ;
210
201
211
202
sb . Append ( valueSpan . Slice ( 0 , index ) ) ;
@@ -238,11 +229,8 @@ public static void HtmlDecode(string? value, TextWriter output)
238
229
239
230
// In the worst case the decoded string has the same length.
240
231
// For small inputs we use stack allocation.
241
- Span < char > buffer = value . Length <= 256 ?
242
- stackalloc char [ 256 ] :
243
- null ;
244
- ValueStringBuilder sb = buffer != null ?
245
- new ValueStringBuilder ( buffer ) :
232
+ ValueStringBuilder sb = value . Length <= 256 ?
233
+ new ValueStringBuilder ( stackalloc char [ 256 ] ) :
246
234
new ValueStringBuilder ( value . Length ) ;
247
235
248
236
sb . Append ( valueSpan . Slice ( 0 , index ) ) ;
0 commit comments