From 9800f2b8aeeef5c295a91bebbf6d6c0a3188ed10 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 16 Sep 2020 16:09:34 -0700 Subject: [PATCH] Use spans instead of Linq (and accidental commit) --- DICUI.Check/Program.cs | 8 -------- DICUI.Library/Aaru/Parameters.cs | 32 ++++++++++---------------------- 2 files changed, 10 insertions(+), 30 deletions(-) diff --git a/DICUI.Check/Program.cs b/DICUI.Check/Program.cs index ff87b9c8..b0db43f5 100644 --- a/DICUI.Check/Program.cs +++ b/DICUI.Check/Program.cs @@ -11,14 +11,6 @@ namespace DICUI.Check { public static void Main(string[] args) { - args = new string[] - { - "cd", - "ibm", - "--use", "aaru", - "B:\\_TEMP\\Aaru Dumps\\MONKEY4_CD2\\MONKEY4_CD2.aif" - }; - // Help options if (args.Length == 0 || args[0] == "-h" || args[0] == "-?") { diff --git a/DICUI.Library/Aaru/Parameters.cs b/DICUI.Library/Aaru/Parameters.cs index 56f7ccd3..912bd4ec 100644 --- a/DICUI.Library/Aaru/Parameters.cs +++ b/DICUI.Library/Aaru/Parameters.cs @@ -2440,7 +2440,6 @@ namespace DICUI.Aaru /// /// CICM Sidecar data generated by Aaru /// String containing the PVD, null on error - /// TODO: Fix this string outputting private static string GeneratePVD(CICMMetadataType cicmSidecar) { // If the object is null, we can't get information from it @@ -2459,24 +2458,14 @@ namespace DICUI.Aaru if (pvdData == null) continue; - /* - Needs to look like this on the other side - 0320 : 20 20 20 20 20 20 20 20 20 20 20 20 20 31 39 39 199 - 0330 : 36 30 39 32 34 31 34 35 34 30 35 30 30 DC 31 39 6092414540500.19 - 0340 : 39 36 30 39 32 34 31 34 35 34 30 35 30 30 DC 30 96092414540500.0 - 0350 : 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 00 000000000000000. - 0360 : 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 - 0370 : 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ - */ - // Build each row in consecutive order string pvd = string.Empty; - pvd += GeneratePVDOutputLine("0320", pvdData, 0); - pvd += GeneratePVDOutputLine("0330", pvdData, 16); - pvd += GeneratePVDOutputLine("0340", pvdData, 32); - pvd += GeneratePVDOutputLine("0350", pvdData, 48); - pvd += GeneratePVDOutputLine("0360", pvdData, 64); - pvd += GeneratePVDOutputLine("0370", pvdData, 80); + pvd += GeneratePVDOutputLine("0320", new ReadOnlySpan(pvdData, 0, 16)); + pvd += GeneratePVDOutputLine("0330", new ReadOnlySpan(pvdData, 16, 16)); + pvd += GeneratePVDOutputLine("0340", new ReadOnlySpan(pvdData, 32, 16)); + pvd += GeneratePVDOutputLine("0350", new ReadOnlySpan(pvdData, 48, 16)); + pvd += GeneratePVDOutputLine("0360", new ReadOnlySpan(pvdData, 64, 16)); + pvd += GeneratePVDOutputLine("0370", new ReadOnlySpan(pvdData, 80, 16)); return pvd; } @@ -2615,17 +2604,16 @@ namespace DICUI.Aaru /// /// Generate a single PVD line from a byte array /// - private static string GeneratePVDOutputLine(string row, byte[] bytes, int startIndex) + private static string GeneratePVDOutputLine(string row, ReadOnlySpan bytes) { string pvdLine = string.Empty; - // TODO: Make this more efficient to generate a single line pvdLine += $"{row} : "; - pvdLine += BitConverter.ToString(bytes.Skip(startIndex).Take(8).ToArray()).Replace("-", " "); + pvdLine += BitConverter.ToString(bytes.Slice(0, 8).ToArray()).Replace("-", " "); pvdLine += " "; - pvdLine += BitConverter.ToString(bytes.Skip(startIndex + 8).Take(8).ToArray()).Replace("-", " "); + pvdLine += BitConverter.ToString(bytes.Slice(8, 8).ToArray().ToArray()).Replace("-", " "); pvdLine += " "; - pvdLine += Encoding.ASCII.GetString(bytes.Skip(startIndex).Take(16).ToArray()).Replace((char)0, '.').Replace('?', '.'); + pvdLine += Encoding.ASCII.GetString(bytes.ToArray()).Replace((char)0, '.').Replace('?', '.'); pvdLine += "\n"; return pvdLine;