Skip to content

Commit

Permalink
Fix zstd dictionary loading
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchLeaders committed Feb 23, 2024
1 parent bfa56a9 commit e3afae3
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/TotkZstd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static void Reload(string zsDicPath)
_decompressors[id] = decompressor;

Compressor compressor = new();
decompressor.LoadDictionary(fileData);
compressor.LoadDictionary(fileData);
_compressors[id] = compressor;
}
}
Expand All @@ -65,14 +65,13 @@ public void TransformSource(IEditorFile handle)
{
Span<byte> buffer = handle.Source.AsSpan();
if (buffer.Length < 5 || buffer.Read<uint>() != ZSTD_MAGIC) {
handle.Source = buffer.ToArray();
return;
}

int id = GetDictionaryId(buffer);
_cache[handle.Id] = id;

if (id > -1 && _decompressors.TryGetValue(id, out Decompressor? decompressor)) {
_cache[handle.Id] = id;
handle.Source = decompressor.Unwrap(buffer).ToArray();
return;
}
Expand Down

0 comments on commit e3afae3

Please sign in to comment.