Skip to content

Commit

Permalink
Improve readability in program code
Browse files Browse the repository at this point in the history
  • Loading branch information
Viir committed Jan 3, 2024
1 parent 362472f commit 801f28d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions implement/read-memory-64-bit/CommonConversion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ static public byte[] ByteArrayFromStringBase16(string base16) =>
.ToArray();

static public string StringBase16FromByteArray(IReadOnlyList<byte> bytes) =>
BitConverter.ToString(bytes as byte[] ?? bytes.ToArray()).Replace("-", "").ToLowerInvariant();
BitConverter.ToString(bytes as byte[] ?? [.. bytes]).Replace("-", "").ToLowerInvariant();

static public byte[] HashSHA256(byte[] input) => SHA256.HashData(input);

Expand Down Expand Up @@ -56,7 +56,7 @@ static public byte[] Inflate(IReadOnlyList<byte> input)
using var inflatedStream = new System.IO.MemoryStream();

using var deflateStream = new System.IO.Compression.DeflateStream(
new System.IO.MemoryStream(input as byte[] ?? input.ToArray()), System.IO.Compression.CompressionMode.Decompress);
new System.IO.MemoryStream(input as byte[] ?? [.. input]), System.IO.Compression.CompressionMode.Decompress);

deflateStream.CopyTo(inflatedStream);

Expand Down
6 changes: 3 additions & 3 deletions implement/read-memory-64-bit/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ PyDictEntry[] ReadActiveDictionaryEntriesFromDictionaryAddress(ulong dictionaryA
entries.Add(new PyDictEntry { hash = hash, key = key, value = value });
}

return entries.ToArray();
return [.. entries];
}

IImmutableDictionary<string, ulong> GetDictionaryEntriesWithStringKeys(ulong dictionaryObjectAddress)
Expand Down Expand Up @@ -1223,7 +1223,7 @@ UITreeNode[] ReadChildren()
pythonObjectAddress: nodeAddress,
pythonObjectTypeName: pythonObjectTypeName,
dictEntriesOfInterest: dictEntriesOfInterestDict,
otherDictEntriesKeys: otherDictEntriesKeys.ToArray(),
otherDictEntriesKeys: [.. otherDictEntriesKeys],
children: ReadChildren()?.Where(child => child != null)?.ToArray()
);
}
Expand Down Expand Up @@ -1562,7 +1562,7 @@ static public byte[] ZipArchiveFromProcessSample(

var zipArchiveEntries =
memoryRegions.ToImmutableDictionary(
region => (IImmutableList<string>)(new[] { "Process", "Memory", $"0x{region.baseAddress:X}" }.ToImmutableList()),
region => (IImmutableList<string>)(["Process", "Memory", $"0x{region.baseAddress:X}"]),
region => region.content.Value.ToArray())
.Add(new[] { "copy-memory-log" }.ToImmutableList(), System.Text.Encoding.UTF8.GetBytes(String.Join("\n", logEntries)))
.AddRange(screenshotEntries);
Expand Down

0 comments on commit 801f28d

Please sign in to comment.