Skip to content

Commit a8c8171

Browse files
Address feedback
Do a single scan with `IndexOfAnyExcept()`.
1 parent 56cdbb7 commit a8c8171

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

  • src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics

‎src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/W3CPropagator.cs‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,14 +296,13 @@ private static bool TryDecodeBaggageValue(ReadOnlySpan<char> valueSpan, out stri
296296
value = null!;
297297
valueSpan = Trim(valueSpan);
298298

299-
#if NET
300-
// If nothing is percent-escaped and everything is already ASCII, the value decodes to itself.
301-
if (valueSpan.IndexOf(Percent) < 0 && valueSpan.IndexOfAnyExceptInRange((char)0, (char)0x7F) < 0)
299+
// If every character is already in the allowed (unescaped) baggage-value set, which
300+
// excludes both '%' and non-ASCII, the value decodes to itself.
301+
if (valueSpan.IndexOfAnyExcept(s_validBaggageValueChars) < 0)
302302
{
303303
value = valueSpan.ToString();
304304
return true;
305305
}
306-
#endif
307306

308307
using ValueStringBuilder vsb = new ValueStringBuilder(stackalloc char[128]);
309308

0 commit comments

Comments
 (0)