Skip to content

Commit

Permalink
Revert "Improvements using Span"
Browse files Browse the repository at this point in the history
This reverts commit e72f153.
  • Loading branch information
gus33000 committed Oct 5, 2024
1 parent e72f153 commit 66517d4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Img2Ffu.Library/Reader/FullFlashUpdateReaderStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ public FullFlashUpdateReaderStream(string FFUFilePath, ulong storeIndex)
catch { }
}

public static ulong GetStoreCount(string FFUFilePath)
public static int GetStoreCount(string FFUFilePath)
{
using FileStream ffuStream = File.Open(FFUFilePath, FileMode.Open, FileAccess.Read, FileShare.Read);
SignedImage ffuFile = new(ffuStream);
return (ulong)ffuFile.Image.Stores.LongCount();
return ffuFile.Image.Stores.Count;
}

private static (int minSectorCount, int minSectorSize)[] ExtractImageManifestStoreInformation(SignedImage ffuFile)
Expand Down Expand Up @@ -146,7 +146,7 @@ private static (int minSectorCount, int minSectorSize)[] ExtractImageManifestSto
long blockMaxStart = 0;
long blockMaxEnd = 0;

for (int i = 0; i < store.WriteDescriptors.LongCount(); i++)
for (int i = 0; i < store.WriteDescriptors.Count; i++)
{
WriteDescriptor writeDescriptor = store.WriteDescriptors[i];
foreach (DiskLocation diskLocation in writeDescriptor.DiskLocations)
Expand Down Expand Up @@ -354,7 +354,7 @@ public void CopyTo(Stream DestinationStream, Action<ulong, ulong> ProgressCallBa
for (int i = 0; i < store.WriteDescriptors.Count; i++)
{
WriteDescriptor writeDescriptor = store.WriteDescriptors[i];
totalBytes += (ulong)writeDescriptor.DiskLocations.LongCount();
totalBytes += (ulong)writeDescriptor.DiskLocations.Count;
}

totalBytes *= (ulong)blockSize * 2u;
Expand Down Expand Up @@ -389,7 +389,7 @@ public void CopyTo(Stream DestinationStream, Action<ulong, ulong> ProgressCallBa

_ = DestinationStream.Seek(OriginalDestinationStreamPosition + virtualPosition, SeekOrigin.Begin);

Span<byte> buffer = image.GetStoreDataBlock(Stream, storeIndex, (ulong)physicalDiskBlockNumber);
byte[] buffer = image.GetStoreDataBlock(Stream, storeIndex, (ulong)physicalDiskBlockNumber);
currentWrittenBytes += (ulong)blockSize;
ProgressCallBack?.Invoke(currentWrittenBytes, totalBytes);

Expand Down

0 comments on commit 66517d4

Please sign in to comment.