mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-07-08 18:16:30 +00:00
Optimize LZMA literal encoder buffer reuse
This commit is contained in:
committed by
GitHub
parent
87a90dbb4f
commit
017d545bc3
@@ -223,12 +223,19 @@ internal partial class Encoder : ICoder, ISetCoderProperties, IWriteCoderPropert
|
||||
_posMask = ((uint)1 << numPosBits) - 1;
|
||||
_numPrevBits = numPrevBits;
|
||||
var numStates = (uint)1 << (_numPrevBits + _numPosBits);
|
||||
if (_models is not null)
|
||||
var requiredModelLength = checked((int)(numStates * 0x300));
|
||||
if (_models is null || _models.Length < requiredModelLength)
|
||||
{
|
||||
ArrayPool<BitEncoder>.Shared.Return(_models);
|
||||
if (_models is not null)
|
||||
{
|
||||
ArrayPool<BitEncoder>.Shared.Return(_models);
|
||||
}
|
||||
_models = ArrayPool<BitEncoder>.Shared.Rent(requiredModelLength);
|
||||
}
|
||||
if (_coders is null || _coders.Length != numStates)
|
||||
{
|
||||
_coders = new Encoder2[numStates];
|
||||
}
|
||||
_models = ArrayPool<BitEncoder>.Shared.Rent(checked((int)(numStates * 0x300)));
|
||||
_coders = new Encoder2[numStates];
|
||||
for (uint i = 0; i < numStates; i++)
|
||||
{
|
||||
_coders[i].Create(_models, checked((int)(i * 0x300)));
|
||||
|
||||
@@ -286,9 +286,9 @@
|
||||
"net10.0": {
|
||||
"Microsoft.NET.ILLink.Tasks": {
|
||||
"type": "Direct",
|
||||
"requested": "[10.0.6, )",
|
||||
"resolved": "10.0.6",
|
||||
"contentHash": "QKuvS0LWX4fjFqeDkyM7Kqt8P3wYTiPD4nwU+9y59n0sCiG714fxDgbbN82vDnzq89AF/PiHl92TP2C4aFDUQA=="
|
||||
"requested": "[10.0.8, )",
|
||||
"resolved": "10.0.8",
|
||||
"contentHash": "dVbSXGIFNR5nZcv2tOLoWI+a9T4jtFd77IYjuND+QVe360qWgAF7H0WtoopYhRw/+SgpGUTyrkrh+65+ClNnfw=="
|
||||
},
|
||||
"Microsoft.NETFramework.ReferenceAssemblies": {
|
||||
"type": "Direct",
|
||||
@@ -388,9 +388,9 @@
|
||||
"net8.0": {
|
||||
"Microsoft.NET.ILLink.Tasks": {
|
||||
"type": "Direct",
|
||||
"requested": "[8.0.26, )",
|
||||
"resolved": "8.0.26",
|
||||
"contentHash": "o7/yVssM2r9Wyln2s9edBd5ANZXqdSdBI+g7JqXkyJmXrhs2WsJp25K5yPnYrTgdKBCjKB8bg+O2oew4sgzFaA=="
|
||||
"requested": "[8.0.27, )",
|
||||
"resolved": "8.0.27",
|
||||
"contentHash": "rQi9TxifHRnXP7lVRZH05DxD2/XGbJp12q0ozcbrlBlBnyyzssFTH/2vLhtKWUp2CT1qVscTrcYTFiwTyKPKRg=="
|
||||
},
|
||||
"Microsoft.NETFramework.ReferenceAssemblies": {
|
||||
"type": "Direct",
|
||||
|
||||
Reference in New Issue
Block a user