Skip to content

Commit b508b84

Browse files
SimonCroppKielekCodeBlanch
authored
[Exporter.Prometheus] remove redundant if in WriteUnicodeNoEscape (#6077)
Co-authored-by: Piotr Kiełkowicz <[email protected]> Co-authored-by: Mikel Blanchard <[email protected]>
1 parent 275a446 commit b508b84

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/PrometheusSerializer.cs

+2-5
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,13 @@ public static int WriteUnicodeNoEscape(byte[] buffer, int cursor, ushort ordinal
102102
buffer[cursor++] = unchecked((byte)(0b_1100_0000 | (ordinal >> 6)));
103103
buffer[cursor++] = unchecked((byte)(0b_1000_0000 | (ordinal & 0b_0011_1111)));
104104
}
105-
else if (ordinal <= 0xFFFF)
105+
else
106106
{
107+
// all other <= 0xFFFF which is ushort.MaxValue
107108
buffer[cursor++] = unchecked((byte)(0b_1110_0000 | (ordinal >> 12)));
108109
buffer[cursor++] = unchecked((byte)(0b_1000_0000 | ((ordinal >> 6) & 0b_0011_1111)));
109110
buffer[cursor++] = unchecked((byte)(0b_1000_0000 | (ordinal & 0b_0011_1111)));
110111
}
111-
else
112-
{
113-
Debug.Assert(ordinal <= 0xFFFF, ".NET string should not go beyond Unicode BMP.");
114-
}
115112

116113
return cursor;
117114
}

0 commit comments

Comments
 (0)