mirror of
https://github.com/SabreTools/MPF.git
synced 2026-07-02 17:24:48 +00:00
Use spans instead of Linq (and accidental commit)
This commit is contained in:
@@ -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] == "-?")
|
||||
{
|
||||
|
||||
@@ -2440,7 +2440,6 @@ namespace DICUI.Aaru
|
||||
/// </summary>
|
||||
/// <param name="cicmSidecar">CICM Sidecar data generated by Aaru</param>
|
||||
/// <returns>String containing the PVD, null on error</returns>
|
||||
/// 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<byte>(pvdData, 0, 16));
|
||||
pvd += GeneratePVDOutputLine("0330", new ReadOnlySpan<byte>(pvdData, 16, 16));
|
||||
pvd += GeneratePVDOutputLine("0340", new ReadOnlySpan<byte>(pvdData, 32, 16));
|
||||
pvd += GeneratePVDOutputLine("0350", new ReadOnlySpan<byte>(pvdData, 48, 16));
|
||||
pvd += GeneratePVDOutputLine("0360", new ReadOnlySpan<byte>(pvdData, 64, 16));
|
||||
pvd += GeneratePVDOutputLine("0370", new ReadOnlySpan<byte>(pvdData, 80, 16));
|
||||
|
||||
return pvd;
|
||||
}
|
||||
@@ -2615,17 +2604,16 @@ namespace DICUI.Aaru
|
||||
/// <summary>
|
||||
/// Generate a single PVD line from a byte array
|
||||
/// </summary>
|
||||
private static string GeneratePVDOutputLine(string row, byte[] bytes, int startIndex)
|
||||
private static string GeneratePVDOutputLine(string row, ReadOnlySpan<byte> 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;
|
||||
|
||||
Reference in New Issue
Block a user