From c0026cb01a017d9fd505969fdb02a1900a04bc86 Mon Sep 17 00:00:00 2001 From: Yoshi Askharoun Date: Tue, 19 Nov 2024 16:40:14 -0600 Subject: [PATCH] Separate length and preamble variables --- UIX/Microsoft/Iris/Markup/ByteCodeReader.cs | 11 ++++++----- UIX/Microsoft/Iris/Markup/ByteCodeWriter.cs | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/UIX/Microsoft/Iris/Markup/ByteCodeReader.cs b/UIX/Microsoft/Iris/Markup/ByteCodeReader.cs index 177f6ad..dce8853 100644 --- a/UIX/Microsoft/Iris/Markup/ByteCodeReader.cs +++ b/UIX/Microsoft/Iris/Markup/ByteCodeReader.cs @@ -251,19 +251,20 @@ namespace Microsoft.Iris.Markup public unsafe string ReadString() { - uint stringLength = ReadUInt16(); - if (stringLength == ushort.MaxValue) + uint preamble = ReadUInt16(); + if (preamble == ushort.MaxValue) return null; - var isUtf16Encoded = ((int)stringLength & (1 << 15)) == 0; - uint byteCount; + var isUtf16Encoded = ((int)preamble & (1 << 15)) == 0; + uint byteCount, stringLength; if (isUtf16Encoded) { + stringLength = preamble; byteCount = stringLength * 2U; } else { - stringLength &= (uint)short.MaxValue; + stringLength = preamble & (uint)short.MaxValue; byteCount = stringLength; } diff --git a/UIX/Microsoft/Iris/Markup/ByteCodeWriter.cs b/UIX/Microsoft/Iris/Markup/ByteCodeWriter.cs index f489104..903f125 100644 --- a/UIX/Microsoft/Iris/Markup/ByteCodeWriter.cs +++ b/UIX/Microsoft/Iris/Markup/ByteCodeWriter.cs @@ -137,11 +137,11 @@ namespace Microsoft.Iris.Markup } } - uint length = (uint)value.Length; + uint preamble = (uint)value.Length; if (!useUtf16) - length |= 1 << 15; + preamble |= 1 << 15; - WriteUInt16((ushort)length); + WriteUInt16((ushort)preamble); foreach (char ch in value) {