From b508b846763851e1da531f3cda61438ebe8566de Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sat, 25 Jan 2025 05:49:16 +1100 Subject: [PATCH] [Exporter.Prometheus] remove redundant if in WriteUnicodeNoEscape (#6077) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Piotr Kiełkowicz Co-authored-by: Mikel Blanchard --- .../Internal/PrometheusSerializer.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/PrometheusSerializer.cs b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/PrometheusSerializer.cs index b182b521506..54cbfac4170 100644 --- a/src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/PrometheusSerializer.cs +++ b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/PrometheusSerializer.cs @@ -102,16 +102,13 @@ public static int WriteUnicodeNoEscape(byte[] buffer, int cursor, ushort ordinal buffer[cursor++] = unchecked((byte)(0b_1100_0000 | (ordinal >> 6))); buffer[cursor++] = unchecked((byte)(0b_1000_0000 | (ordinal & 0b_0011_1111))); } - else if (ordinal <= 0xFFFF) + else { + // all other <= 0xFFFF which is ushort.MaxValue buffer[cursor++] = unchecked((byte)(0b_1110_0000 | (ordinal >> 12))); buffer[cursor++] = unchecked((byte)(0b_1000_0000 | ((ordinal >> 6) & 0b_0011_1111))); buffer[cursor++] = unchecked((byte)(0b_1000_0000 | (ordinal & 0b_0011_1111))); } - else - { - Debug.Assert(ordinal <= 0xFFFF, ".NET string should not go beyond Unicode BMP."); - } return cursor; }