Skip to content

Commit

Permalink
Remove unnecessary read
Browse files Browse the repository at this point in the history
The FatStream already performs a read. Removing this did not cause any tests to fail.
  • Loading branch information
GoldenretriverYT committed Dec 10, 2023
1 parent 4a224fe commit 6c641d9
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions source/Cosmos.System2/FileSystem/FAT/FatFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -955,24 +955,17 @@ internal void Write(long aCluster, byte[] aData, long aSize = 0, long aOffset =
{
aSize = BytesPerCluster;
}

byte[] xData = NewBlockArray();
Read(aCluster, ref xData);


Array.Copy(aData, 0, xData, aOffset, aSize);


if (mFatType == FatTypeEnum.Fat32)
{
long xSector = DataSector + (aCluster - RootCluster) * SectorsPerCluster;
Device.WriteBlock((ulong)xSector, SectorsPerCluster, ref xData);
Device.WriteBlock((ulong)xSector, SectorsPerCluster, ref aData);
}
else
{
Device.WriteBlock((ulong)aCluster, RootSectorCount, ref xData);
Device.WriteBlock((ulong)aCluster, RootSectorCount, ref aData);
}

GCImplementation.Free(xData);
}

/// <summary>
Expand Down

0 comments on commit 6c641d9

Please sign in to comment.