Skip to content

Commit

Permalink
Improve code readability in BplistReader
Browse files Browse the repository at this point in the history
  • Loading branch information
iamcarbon committed Feb 2, 2024
1 parent e6d86bd commit f4437f5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions MetadataExtractor/Formats/Apple/BplistReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,20 @@ public static PropertyListResults Parse(byte[] bplist)

Trailer trailer = ReadTrailer();

var reader = new BufferReader(bplist.AsSpan(checked((int)(trailer.OffsetTableOffset + trailer.TopObject))), isBigEndian: true);
int offset = checked((int)(trailer.OffsetTableOffset + trailer.TopObject));
var reader = new BufferReader(bplist.AsSpan(offset), isBigEndian: true);

int[] offsets = new int[(int)trailer.NumObjects];

for (long i = 0; i < trailer.NumObjects; i++)
for (int i = 0; i < (int)trailer.NumObjects; i++)
{
if (trailer.OffsetIntSize == 1)
{
offsets[(int)i] = reader.GetByte();
offsets[i] = reader.GetByte();
}
else if (trailer.OffsetIntSize == 2)
{
offsets[(int)i] = reader.GetUInt16();
offsets[i] = reader.GetUInt16();
}
}

Expand Down

0 comments on commit f4437f5

Please sign in to comment.