mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-09-23 07:25:11 +00:00
Merge pull request #1084 from adamhathcock/copilot/fix-handled-system-exception
Avoid NotSupportedException overhead in SharpCompressStream for non-seekable streams
This commit is contained in:
@@ -57,14 +57,8 @@ public class SharpCompressStream : Stream, IStreamStack
|
||||
{
|
||||
ValidateBufferState(); // Add here
|
||||
}
|
||||
try
|
||||
{
|
||||
_internalPosition = Stream.Position;
|
||||
}
|
||||
catch
|
||||
{
|
||||
_internalPosition = 0;
|
||||
}
|
||||
// Check CanSeek before accessing Position to avoid exception overhead on non-seekable streams.
|
||||
_internalPosition = Stream.CanSeek ? Stream.Position : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -136,14 +130,8 @@ public class SharpCompressStream : Stream, IStreamStack
|
||||
_readOnly = !Stream.CanSeek;
|
||||
|
||||
((IStreamStack)this).SetBuffer(bufferSize, forceBuffer);
|
||||
try
|
||||
{
|
||||
_baseInitialPos = stream.Position;
|
||||
}
|
||||
catch
|
||||
{
|
||||
_baseInitialPos = 0;
|
||||
}
|
||||
// Check CanSeek before accessing Position to avoid exception overhead on non-seekable streams.
|
||||
_baseInitialPos = Stream.CanSeek ? Stream.Position : 0;
|
||||
|
||||
#if DEBUG_STREAMS
|
||||
this.DebugConstruct(typeof(SharpCompressStream));
|
||||
|
||||
Reference in New Issue
Block a user