Skip to content

Commit

Permalink
Remove unnecessary loop in _patch_add_old_with_rle
Browse files Browse the repository at this point in the history
  • Loading branch information
neon-nyan committed Aug 13, 2023
1 parent 2715d9a commit 2aea0dd
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions Hi3Helper.SharpHDiffPatch/PatchCore/PatchCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,20 +248,14 @@ private static void WriteCoverStreamToOutput(Stream[] clips, Stream inputStream,
private static void _patch_add_old_with_rle(Stream outCache, ref RLERefClipStruct rleLoader, long oldPos, long addLength)
{
long lastPos = outCache.Position;
while (addLength > 0)
{
long decodeStep = addLength;
rleLoader.rleInputClip.BaseStream.Position = oldPos;

byte[] tempBuffer = new byte[decodeStep];
rleLoader.rleInputClip.BaseStream.Read(tempBuffer);
outCache.Write(tempBuffer);
outCache.Position = lastPos;
_TBytesRle_load_stream_decode_add(ref rleLoader, outCache, decodeStep);
long decodeStep = addLength;
rleLoader.rleInputClip.BaseStream.Position = oldPos;

oldPos += decodeStep;
addLength -= decodeStep;
}
byte[] tempBuffer = new byte[decodeStep];
rleLoader.rleInputClip.BaseStream.Read(tempBuffer);
outCache.Write(tempBuffer);
outCache.Position = lastPos;
_TBytesRle_load_stream_decode_add(ref rleLoader, outCache, decodeStep);
}

private static void _TOutStreamCache_copyFromClip(Stream outCache, BinaryReader copyReader, long copyLength)
Expand Down

0 comments on commit 2aea0dd

Please sign in to comment.