update csharpier

This commit is contained in:
Adam Hathcock
2024-03-14 08:29:30 +00:00
parent 8072eb1212
commit 93e181cfd9
12 changed files with 63 additions and 66 deletions

View File

@@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"csharpier": {
"version": "0.26.7",
"version": "0.27.3",
"commands": [
"dotnet-csharpier"
]

View File

@@ -40,9 +40,11 @@ public class RarArchive : AbstractArchive<RarArchiveEntry, RarVolume>
streams[1].Position = 0;
SrcStream.Position = 0;
return srcStream.Streams.Select(
a => new StreamRarArchiveVolume(a, ReaderOptions, idx++)
);
return srcStream.Streams.Select(a => new StreamRarArchiveVolume(
a,
ReaderOptions,
idx++
));
}
else //split mode or single file
{

View File

@@ -52,8 +52,8 @@ internal class DirectoryEntryHeader : ZipFileEntry
LoadExtra(extra);
var unicodePathExtra = Extra.FirstOrDefault(
u => u.Type == ExtraDataType.UnicodePathExtraField
var unicodePathExtra = Extra.FirstOrDefault(u =>
u.Type == ExtraDataType.UnicodePathExtraField
);
if (unicodePathExtra != null && ArchiveEncoding.Forced == null)
{

View File

@@ -42,8 +42,8 @@ internal class LocalEntryHeader : ZipFileEntry
LoadExtra(extra);
var unicodePathExtra = Extra.FirstOrDefault(
u => u.Type == ExtraDataType.UnicodePathExtraField
var unicodePathExtra = Extra.FirstOrDefault(u =>
u.Type == ExtraDataType.UnicodePathExtraField
);
if (unicodePathExtra != null && ArchiveEncoding.Forced == null)
{

View File

@@ -97,13 +97,12 @@ internal class StreamingZipHeaderFactory : ZipHeaderFactory
if (header.ZipHeaderType == ZipHeaderType.LocalEntry)
{
var local_header = ((LocalEntryHeader)header);
var dir_header = _entries?.FirstOrDefault(
entry =>
entry.Key == local_header.Name
&& local_header.CompressedSize == 0
&& local_header.UncompressedSize == 0
&& local_header.Crc == 0
&& local_header.IsDirectory == false
var dir_header = _entries?.FirstOrDefault(entry =>
entry.Key == local_header.Name
&& local_header.CompressedSize == 0
&& local_header.UncompressedSize == 0
&& local_header.Crc == 0
&& local_header.IsDirectory == false
);
if (dir_header != null)

View File

@@ -142,8 +142,8 @@ internal class ZipHeaderFactory
if (entryHeader.CompressionMethod == ZipCompressionMethod.WinzipAes)
{
var data = entryHeader.Extra.SingleOrDefault(
x => x.Type == ExtraDataType.WinZipAes
var data = entryHeader.Extra.SingleOrDefault(x =>
x.Type == ExtraDataType.WinZipAes
);
if (data != null)
{

View File

@@ -243,8 +243,8 @@ internal sealed class InflaterManaged
private void Reset() =>
_state = //_hasFormatReader ?
//InflaterState.ReadingHeader : // start by reading Header info
InflaterState.ReadingBFinal; // start by reading BFinal bit
//InflaterState.ReadingHeader : // start by reading Header info
InflaterState.ReadingBFinal; // start by reading BFinal bit
public void SetInput(byte[] inputBytes, int offset, int length) =>
_input.SetInput(inputBytes, offset, length); // append the bytes

View File

@@ -318,9 +318,8 @@ public class Decoder : ICoder, ISetDecoderProperties // ,System.IO.Stream
{
var posState = (uint)outWindow._total & _posStateMask;
if (
_isMatchDecoders[
(_state._index << Base.K_NUM_POS_STATES_BITS_MAX) + posState
].Decode(rangeDecoder) == 0
_isMatchDecoders[(_state._index << Base.K_NUM_POS_STATES_BITS_MAX) + posState]
.Decode(rangeDecoder) == 0
)
{
byte b;
@@ -355,7 +354,8 @@ public class Decoder : ICoder, ISetDecoderProperties // ,System.IO.Stream
if (
_isRep0LongDecoders[
(_state._index << Base.K_NUM_POS_STATES_BITS_MAX) + posState
].Decode(rangeDecoder) == 0
]
.Decode(rangeDecoder) == 0
)
{
_state.UpdateShortRep();

View File

@@ -553,9 +553,8 @@ internal class Encoder : ICoder, ISetCoderProperties, IWriteCoderProperties
if (repIndex == 0)
{
price = _isRepG0[state._index].GetPrice0();
price += _isRep0Long[
(state._index << Base.K_NUM_POS_STATES_BITS_MAX) + posState
].GetPrice1();
price += _isRep0Long[(state._index << Base.K_NUM_POS_STATES_BITS_MAX) + posState]
.GetPrice1();
}
else
{
@@ -713,9 +712,8 @@ internal class Encoder : ICoder, ISetCoderProperties, IWriteCoderProperties
.GetPrice(!_state.IsCharState(), matchByte, currentByte);
_optimum[1].MakeAsChar();
var matchPrice = _isMatch[
(_state._index << Base.K_NUM_POS_STATES_BITS_MAX) + posState
].GetPrice1();
var matchPrice = _isMatch[(_state._index << Base.K_NUM_POS_STATES_BITS_MAX) + posState]
.GetPrice1();
var repMatchPrice = matchPrice + _isRep[_state._index].GetPrice1();
if (matchByte == currentByte)
@@ -995,9 +993,8 @@ internal class Encoder : ICoder, ISetCoderProperties, IWriteCoderProperties
var posStateNext = (position + 1) & _posStateMask;
var nextRepMatchPrice =
curAnd1Price
+ _isMatch[
(state2._index << Base.K_NUM_POS_STATES_BITS_MAX) + posStateNext
].GetPrice1()
+ _isMatch[(state2._index << Base.K_NUM_POS_STATES_BITS_MAX) + posStateNext]
.GetPrice1()
+ _isRep[state2._index].GetPrice1();
{
var offset = cur + 1 + lenTest2;
@@ -1069,7 +1066,8 @@ internal class Encoder : ICoder, ISetCoderProperties, IWriteCoderProperties
+ GetRepPrice(repIndex, lenTest, state, posState)
+ _isMatch[
(state2._index << Base.K_NUM_POS_STATES_BITS_MAX) + posStateNext
].GetPrice0()
]
.GetPrice0()
+ _literalEncoder
.GetSubCoder(
position + lenTest,
@@ -1088,7 +1086,8 @@ internal class Encoder : ICoder, ISetCoderProperties, IWriteCoderProperties
curAndLenCharPrice
+ _isMatch[
(state2._index << Base.K_NUM_POS_STATES_BITS_MAX) + posStateNext
].GetPrice1();
]
.GetPrice1();
var nextRepMatchPrice = nextMatchPrice + _isRep[state2._index].GetPrice1();
// for(; lenTest2 >= 2; lenTest2--)
@@ -1174,7 +1173,8 @@ internal class Encoder : ICoder, ISetCoderProperties, IWriteCoderProperties
+ _isMatch[
(state2._index << Base.K_NUM_POS_STATES_BITS_MAX)
+ posStateNext
].GetPrice0()
]
.GetPrice0()
+ _literalEncoder
.GetSubCoder(
position + lenTest,
@@ -1194,7 +1194,8 @@ internal class Encoder : ICoder, ISetCoderProperties, IWriteCoderProperties
+ _isMatch[
(state2._index << Base.K_NUM_POS_STATES_BITS_MAX)
+ posStateNext
].GetPrice1();
]
.GetPrice1();
var nextRepMatchPrice =
nextMatchPrice + _isRep[state2._index].GetPrice1();
@@ -1243,10 +1244,8 @@ internal class Encoder : ICoder, ISetCoderProperties, IWriteCoderProperties
return;
}
_isMatch[(_state._index << Base.K_NUM_POS_STATES_BITS_MAX) + posState].Encode(
_rangeEncoder,
1
);
_isMatch[(_state._index << Base.K_NUM_POS_STATES_BITS_MAX) + posState]
.Encode(_rangeEncoder, 1);
_isRep[_state._index].Encode(_rangeEncoder, 0);
_state.UpdateMatch();
var len = Base.K_MATCH_MIN_LEN;
@@ -1321,10 +1320,8 @@ internal class Encoder : ICoder, ISetCoderProperties, IWriteCoderProperties
// it's not used
ReadMatchDistances(out var len, out var numDistancePairs);
var posState = (uint)(_nowPos64) & _posStateMask;
_isMatch[(_state._index << Base.K_NUM_POS_STATES_BITS_MAX) + posState].Encode(
_rangeEncoder,
0
);
_isMatch[(_state._index << Base.K_NUM_POS_STATES_BITS_MAX) + posState]
.Encode(_rangeEncoder, 0);
_state.UpdateChar();
var curByte = _matchFinder.GetIndexByte((int)(0 - _additionalOffset));
_literalEncoder

View File

@@ -395,10 +395,8 @@ internal class Allocator
unitCountDifference -= unitCount;
}
_memoryNodes[UNITS_TO_INDEX[unitCountDifference - 1]].Insert(
newPointer,
unitCountDifference
);
_memoryNodes[UNITS_TO_INDEX[unitCountDifference - 1]]
.Insert(newPointer, unitCountDifference);
}
private void GlueFreeBlocks()
@@ -457,10 +455,11 @@ internal class Allocator
if (INDEX_TO_UNITS[index] != unitCount)
{
var unitCountDifference = unitCount - INDEX_TO_UNITS[--index];
_memoryNodes[unitCountDifference - 1].Insert(
memoryNode0 + (unitCount - unitCountDifference),
unitCountDifference
);
_memoryNodes[unitCountDifference - 1]
.Insert(
memoryNode0 + (unitCount - unitCountDifference),
unitCountDifference
);
}
_memoryNodes[index].Insert(memoryNode0, INDEX_TO_UNITS[index]);

View File

@@ -198,8 +198,8 @@ public class TarArchiveTests : ArchiveTests
using (var archive = TarArchive.Open(unmodified))
{
var entry = archive.Entries.Single(
x => x.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)
var entry = archive.Entries.Single(x =>
x.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)
);
archive.RemoveEntry(entry);
archive.SaveTo(scratchPath, CompressionType.None);

View File

@@ -192,8 +192,8 @@ public class ZipArchiveTests : ArchiveTests
using (var archive = ZipArchive.Open(unmodified))
{
var entry = archive.Entries.Single(
x => x.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)
var entry = archive.Entries.Single(x =>
x.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)
);
archive.RemoveEntry(entry);
@@ -250,18 +250,18 @@ public class ZipArchiveTests : ArchiveTests
using (ZipArchive vfs = (ZipArchive)ArchiveFactory.Open(scratchPath))
{
var e = vfs.Entries.First(
v => v.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)
var e = vfs.Entries.First(v =>
v.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)
);
vfs.RemoveEntry(e);
Assert.Null(
vfs.Entries.FirstOrDefault(
v => v.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)
vfs.Entries.FirstOrDefault(v =>
v.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)
)
);
Assert.Null(
((IArchive)vfs).Entries.FirstOrDefault(
v => v.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)
((IArchive)vfs).Entries.FirstOrDefault(v =>
v.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)
)
);
}
@@ -399,13 +399,13 @@ public class ZipArchiveTests : ArchiveTests
{
archive.AddAllFromDirectory(SCRATCH_FILES_PATH);
archive.RemoveEntry(
archive.Entries.Single(
x => x.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)
archive.Entries.Single(x =>
x.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)
)
);
Assert.Null(
archive.Entries.FirstOrDefault(
x => x.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)
archive.Entries.FirstOrDefault(x =>
x.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)
)
);
}