From 9f161bf40e1764f9780d0f8f77008e0414b20b75 Mon Sep 17 00:00:00 2001 From: Morilli <35152647+Morilli@users.noreply.github.com> Date: Sun, 6 Oct 2024 05:55:23 +0200 Subject: [PATCH] Simplify Serializer array sync handling val == null is impossible, so the check is completely useless. --- src/BizHawk.Common/Serializer.cs | 42 ++++++-------------------------- 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/src/BizHawk.Common/Serializer.cs b/src/BizHawk.Common/Serializer.cs index 59a750f452..167b2a0bd5 100644 --- a/src/BizHawk.Common/Serializer.cs +++ b/src/BizHawk.Common/Serializer.cs @@ -209,11 +209,7 @@ namespace BizHawk.Common } else if (IsReader) { - val = _br.ReadByteBuffer(false).ToBoolBuffer(); - if (val == null && !useNull) - { - val = Array.Empty(); - } + val = _br.ReadByteBuffer(false)!.ToBoolBuffer(); } else { @@ -250,11 +246,7 @@ namespace BizHawk.Common } else if (IsReader) { - val = _br.ReadByteBuffer(false).ToShortBuffer(); - if (val == null && !useNull) - { - val = Array.Empty(); - } + val = _br.ReadByteBuffer(false)!.ToShortBuffer(); } else { @@ -270,11 +262,7 @@ namespace BizHawk.Common } else if (IsReader) { - val = _br.ReadByteBuffer(false).ToUShortBuffer(); - if (val == null && !useNull) - { - val = Array.Empty(); - } + val = _br.ReadByteBuffer(false)!.ToUShortBuffer(); } else { @@ -334,11 +322,7 @@ namespace BizHawk.Common } else if (IsReader) { - val = _br.ReadByteBuffer(false).ToIntBuffer(); - if (val == null && !useNull) - { - val = Array.Empty(); - } + val = _br.ReadByteBuffer(false)!.ToIntBuffer(); } else { @@ -376,11 +360,7 @@ namespace BizHawk.Common } else if (IsReader) { - val = _br.ReadByteBuffer(false).ToUIntBuffer(); - if (val == null && !useNull) - { - val = Array.Empty(); - } + val = _br.ReadByteBuffer(false)!.ToUIntBuffer(); } else { @@ -418,11 +398,7 @@ namespace BizHawk.Common } else if (IsReader) { - val = _br.ReadByteBuffer(false).ToFloatBuffer(); - if (val == null && !useNull) - { - val = Array.Empty(); - } + val = _br.ReadByteBuffer(false)!.ToFloatBuffer(); } else { @@ -460,11 +436,7 @@ namespace BizHawk.Common } else if (IsReader) { - val = _br.ReadByteBuffer(false).ToDoubleBuffer(); - if (val == null && !useNull) - { - val = Array.Empty(); - } + val = _br.ReadByteBuffer(false)!.ToDoubleBuffer(); } else {