1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-25 11:08:02 +02:00

Remove unneeded physical flushing with BufferedFileStream

This commit is contained in:
Brian Fiete 2025-03-28 12:18:18 -04:00
parent 46db1b61d4
commit b549c820c7

View file

@ -38,7 +38,7 @@ namespace System.IO
public ~this() public ~this()
{ {
Flush(); FlushBuffer();
} }
public override Result<void> Seek(int64 pos, SeekKind seekKind = .Absolute) public override Result<void> Seek(int64 pos, SeekKind seekKind = .Absolute)
@ -84,7 +84,7 @@ namespace System.IO
data.RemoveFromStart((.)spaceLeft); data.RemoveFromStart((.)spaceLeft);
} }
Try!(Flush()); Try!(FlushBuffer());
if ((mBuffer == null) || (data.Length > mBuffer.Count)) if ((mBuffer == null) || (data.Length > mBuffer.Count))
{ {
@ -114,7 +114,7 @@ namespace System.IO
if ((mWriteDirtyEnd >= 0) && (mWriteDirtyEnd != mPos)) if ((mWriteDirtyEnd >= 0) && (mWriteDirtyEnd != mPos))
{ {
Try!(Flush()); Try!(FlushBuffer());
} }
int writeCount = 0; int writeCount = 0;
@ -138,7 +138,7 @@ namespace System.IO
} }
} }
Try!(Flush()); Try!(FlushBuffer());
if ((mBuffer == null) || (data.Length > mBuffer.Count)) if ((mBuffer == null) || (data.Length > mBuffer.Count))
{ {
@ -158,7 +158,7 @@ namespace System.IO
return writeCount; return writeCount;
} }
public override Result<void> Flush() protected Result<void> FlushBuffer()
{ {
if (mWriteDirtyPos >= 0) if (mWriteDirtyPos >= 0)
{ {
@ -170,6 +170,11 @@ namespace System.IO
return .Ok; return .Ok;
} }
public override Result<void> Flush()
{
return FlushBuffer();
}
public override Result<void> Close() public override Result<void> Close()
{ {
let ret = Flush(); let ret = Flush();