From 554d326819aa6a5e857a8e38b91443a93d15dd1a Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Wed, 30 Nov 2022 19:58:02 +0000 Subject: [PATCH] Call ZString.CreateUtf8StringBuilder Don't instantiate directly, let ZString handle it --- .../src/Entities/VirtualParadiseParticleEmitterObject.cs | 4 ++-- VpSharp/src/Entities/VirtualParadisePathObject.cs | 2 +- VpSharp/src/Extensions/SpanExtensions.cs | 8 ++++---- .../src/Internal/ValueConverters/IntToBoolConverter.cs | 2 +- .../ValueConverters/MillisecondToTimeSpanConverter.cs | 2 +- VpSharp/src/Internal/ValueConverters/Vector2Converter.cs | 2 +- VpSharp/src/Internal/ValueConverters/Vector3Converter.cs | 2 +- .../Internal/ValueConverters/Vector3ToColorConverter.cs | 2 +- VpSharp/src/Internal/ValueConverters/Vector3dConverter.cs | 2 +- .../Internal/ValueConverters/Vector4ToColorConverter.cs | 2 +- .../Internal/ValueConverters/Vector4ToVector3Converter.cs | 2 +- .../ValueConverters/VectorToNthComponentConverter.cs | 2 +- 12 files changed, 16 insertions(+), 16 deletions(-) diff --git a/VpSharp/src/Entities/VirtualParadiseParticleEmitterObject.cs b/VpSharp/src/Entities/VirtualParadiseParticleEmitterObject.cs index 3947711..f8572ec 100644 --- a/VpSharp/src/Entities/VirtualParadiseParticleEmitterObject.cs +++ b/VpSharp/src/Entities/VirtualParadiseParticleEmitterObject.cs @@ -270,8 +270,8 @@ public sealed class VirtualParadiseParticleEmitterObject : VirtualParadiseObject Span text = stackalloc char[data.Length]; Encoding.UTF8.GetChars(data, text); - using var keyBuffer = new Utf8ValueStringBuilder(false); - using var valueBuffer = new Utf8ValueStringBuilder(false); + using Utf8ValueStringBuilder keyBuffer = ZString.CreateUtf8StringBuilder(); + using Utf8ValueStringBuilder valueBuffer = ZString.CreateUtf8StringBuilder(); var isKey = true; for (var index = 0; index < text.Length; index++) diff --git a/VpSharp/src/Entities/VirtualParadisePathObject.cs b/VpSharp/src/Entities/VirtualParadisePathObject.cs index 0391b7f..74ecb24 100644 --- a/VpSharp/src/Entities/VirtualParadisePathObject.cs +++ b/VpSharp/src/Entities/VirtualParadisePathObject.cs @@ -45,7 +45,7 @@ public sealed class VirtualParadisePathObject : VirtualParadiseObject Span chars = stackalloc char[data.Length]; Encoding.UTF8.GetChars(data, chars); - using var buffer = new Utf8ValueStringBuilder(false); + using Utf8ValueStringBuilder buffer = ZString.CreateUtf8StringBuilder(); int index; // version diff --git a/VpSharp/src/Extensions/SpanExtensions.cs b/VpSharp/src/Extensions/SpanExtensions.cs index 44af69b..4e71d94 100644 --- a/VpSharp/src/Extensions/SpanExtensions.cs +++ b/VpSharp/src/Extensions/SpanExtensions.cs @@ -62,7 +62,7 @@ internal static class SpanExtensions float y = 0; byte spaceCount = 0; - using var buffer = new Utf8ValueStringBuilder(false); + using Utf8ValueStringBuilder buffer = ZString.CreateUtf8StringBuilder(); for (var index = 0; index < value.Length; index++) { char current = value[index]; @@ -107,7 +107,7 @@ internal static class SpanExtensions float z = 0; byte spaceCount = 0; - using var buffer = new Utf8ValueStringBuilder(false); + using Utf8ValueStringBuilder buffer = ZString.CreateUtf8StringBuilder(); for (var index = 0; index < value.Length; index++) { char current = value[index]; @@ -155,7 +155,7 @@ internal static class SpanExtensions double z = 0; byte spaceCount = 0; - using var buffer = new Utf8ValueStringBuilder(false); + using Utf8ValueStringBuilder buffer = ZString.CreateUtf8StringBuilder(); for (var index = 0; index < value.Length; index++) { char current = value[index]; @@ -204,7 +204,7 @@ internal static class SpanExtensions float w = 0; byte spaceCount = 0; - using var buffer = new Utf8ValueStringBuilder(false); + using Utf8ValueStringBuilder buffer = ZString.CreateUtf8StringBuilder(); for (var index = 0; index < value.Length; index++) { char current = value[index]; diff --git a/VpSharp/src/Internal/ValueConverters/IntToBoolConverter.cs b/VpSharp/src/Internal/ValueConverters/IntToBoolConverter.cs index 97854e0..09aa44c 100644 --- a/VpSharp/src/Internal/ValueConverters/IntToBoolConverter.cs +++ b/VpSharp/src/Internal/ValueConverters/IntToBoolConverter.cs @@ -10,7 +10,7 @@ internal sealed class IntToBoolConverter : ValueConverter /// public override void Deserialize(TextReader reader, out bool result) { - using var builder = new Utf8ValueStringBuilder(false); + using Utf8ValueStringBuilder builder = ZString.CreateUtf8StringBuilder(); int read; while ((read = reader.Read()) != -1) { diff --git a/VpSharp/src/Internal/ValueConverters/MillisecondToTimeSpanConverter.cs b/VpSharp/src/Internal/ValueConverters/MillisecondToTimeSpanConverter.cs index 19213a0..9f362d2 100644 --- a/VpSharp/src/Internal/ValueConverters/MillisecondToTimeSpanConverter.cs +++ b/VpSharp/src/Internal/ValueConverters/MillisecondToTimeSpanConverter.cs @@ -10,7 +10,7 @@ internal sealed class MillisecondToTimeSpanConverter : ValueConverter /// public override void Deserialize(TextReader reader, out TimeSpan result) { - using var builder = new Utf8ValueStringBuilder(false); + using Utf8ValueStringBuilder builder = ZString.CreateUtf8StringBuilder(); int read; while ((read = reader.Read()) != -1) { diff --git a/VpSharp/src/Internal/ValueConverters/Vector2Converter.cs b/VpSharp/src/Internal/ValueConverters/Vector2Converter.cs index 0d324f6..ba1710f 100644 --- a/VpSharp/src/Internal/ValueConverters/Vector2Converter.cs +++ b/VpSharp/src/Internal/ValueConverters/Vector2Converter.cs @@ -11,7 +11,7 @@ internal sealed class Vector2Converter : ValueConverter /// public override void Deserialize(TextReader reader, out Vector2 result) { - using var builder = new Utf8ValueStringBuilder(false); + using Utf8ValueStringBuilder builder = ZString.CreateUtf8StringBuilder(); var spaceCount = 0; while (true) diff --git a/VpSharp/src/Internal/ValueConverters/Vector3Converter.cs b/VpSharp/src/Internal/ValueConverters/Vector3Converter.cs index 3585290..1abf600 100644 --- a/VpSharp/src/Internal/ValueConverters/Vector3Converter.cs +++ b/VpSharp/src/Internal/ValueConverters/Vector3Converter.cs @@ -11,7 +11,7 @@ internal sealed class Vector3Converter : ValueConverter /// public override void Deserialize(TextReader reader, out Vector3 result) { - using var builder = new Utf8ValueStringBuilder(false); + using Utf8ValueStringBuilder builder = ZString.CreateUtf8StringBuilder(); var spaceCount = 0; while (true) diff --git a/VpSharp/src/Internal/ValueConverters/Vector3ToColorConverter.cs b/VpSharp/src/Internal/ValueConverters/Vector3ToColorConverter.cs index 8a744ba..a9d6745 100644 --- a/VpSharp/src/Internal/ValueConverters/Vector3ToColorConverter.cs +++ b/VpSharp/src/Internal/ValueConverters/Vector3ToColorConverter.cs @@ -10,7 +10,7 @@ internal sealed class Vector3ToColorConverter : ValueConverter /// public override void Deserialize(TextReader reader, out ColorF result) { - using var builder = new Utf8ValueStringBuilder(false); + using Utf8ValueStringBuilder builder = ZString.CreateUtf8StringBuilder(); var spaceCount = 0; while (true) diff --git a/VpSharp/src/Internal/ValueConverters/Vector3dConverter.cs b/VpSharp/src/Internal/ValueConverters/Vector3dConverter.cs index 4920b41..076c88c 100644 --- a/VpSharp/src/Internal/ValueConverters/Vector3dConverter.cs +++ b/VpSharp/src/Internal/ValueConverters/Vector3dConverter.cs @@ -10,7 +10,7 @@ internal sealed class Vector3dConverter : ValueConverter /// public override void Deserialize(TextReader reader, out Vector3d result) { - using var builder = new Utf8ValueStringBuilder(false); + using Utf8ValueStringBuilder builder = ZString.CreateUtf8StringBuilder(); var spaceCount = 0; while (true) diff --git a/VpSharp/src/Internal/ValueConverters/Vector4ToColorConverter.cs b/VpSharp/src/Internal/ValueConverters/Vector4ToColorConverter.cs index ba5eeb4..1aec041 100644 --- a/VpSharp/src/Internal/ValueConverters/Vector4ToColorConverter.cs +++ b/VpSharp/src/Internal/ValueConverters/Vector4ToColorConverter.cs @@ -10,7 +10,7 @@ internal sealed class Vector4ToColorConverter : ValueConverter /// public override void Deserialize(TextReader reader, out ColorF result) { - using var builder = new Utf8ValueStringBuilder(false); + using Utf8ValueStringBuilder builder = ZString.CreateUtf8StringBuilder(); var spaceCount = 0; while (true) diff --git a/VpSharp/src/Internal/ValueConverters/Vector4ToVector3Converter.cs b/VpSharp/src/Internal/ValueConverters/Vector4ToVector3Converter.cs index 5983c03..75e8af6 100644 --- a/VpSharp/src/Internal/ValueConverters/Vector4ToVector3Converter.cs +++ b/VpSharp/src/Internal/ValueConverters/Vector4ToVector3Converter.cs @@ -11,7 +11,7 @@ internal sealed class Vector4ToVector3Converter : ValueConverter /// public override void Deserialize(TextReader reader, out Vector3 result) { - using var builder = new Utf8ValueStringBuilder(false); + using Utf8ValueStringBuilder builder = ZString.CreateUtf8StringBuilder(); var spaceCount = 0; while (true) diff --git a/VpSharp/src/Internal/ValueConverters/VectorToNthComponentConverter.cs b/VpSharp/src/Internal/ValueConverters/VectorToNthComponentConverter.cs index f0b7891..04fd335 100644 --- a/VpSharp/src/Internal/ValueConverters/VectorToNthComponentConverter.cs +++ b/VpSharp/src/Internal/ValueConverters/VectorToNthComponentConverter.cs @@ -18,7 +18,7 @@ internal sealed class VectorToNthComponentConverter : ValueConverter /// public override void Deserialize(TextReader reader, out float result) { - using var builder = new Utf8ValueStringBuilder(false); + using Utf8ValueStringBuilder builder = ZString.CreateUtf8StringBuilder(); var spaceCount = 0; while (true)