mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Optimized reading for empty run of blocks in partclone.
This commit is contained in:
@@ -219,14 +219,7 @@ namespace DiscImageChef.DiscImages
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IsEmpty(ulong sectorAddress)
|
||||
{
|
||||
if(sectorAddress > (ulong)byteMap.LongLength - 1)
|
||||
throw new ArgumentOutOfRangeException(nameof(sectorAddress), string.Format("Sector address {0} not found", sectorAddress));
|
||||
|
||||
return byteMap[sectorAddress] == 0;
|
||||
}
|
||||
|
||||
// TODO: Find a way to optimize this, it's insanely slow!
|
||||
ulong BlockOffset(ulong sectorAddress)
|
||||
{
|
||||
ulong blockOff = 0;
|
||||
@@ -243,7 +236,7 @@ namespace DiscImageChef.DiscImages
|
||||
if(sectorAddress > ImageInfo.sectors - 1)
|
||||
throw new ArgumentOutOfRangeException(nameof(sectorAddress), string.Format("Sector address {0} not found", sectorAddress));
|
||||
|
||||
if(IsEmpty(sectorAddress))
|
||||
if(byteMap[sectorAddress] == 0)
|
||||
return new byte[pHdr.blockSize];
|
||||
|
||||
byte[] sector;
|
||||
@@ -275,6 +268,19 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
|
||||
bool allEmpty = true;
|
||||
for(uint i = 0; i < length; i++)
|
||||
{
|
||||
if(byteMap[sectorAddress + i] != 0)
|
||||
{
|
||||
allEmpty = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(allEmpty)
|
||||
return new byte[pHdr.blockSize * length];
|
||||
|
||||
for(uint i = 0; i < length; i++)
|
||||
{
|
||||
byte[] sector = ReadSector(sectorAddress + i);
|
||||
|
||||
Reference in New Issue
Block a user