Skip to content

Commit 6ea6db6

Browse files
committed
Optimized 'Read8' method.
1 parent 53dedef commit 6ea6db6

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

LibIPS.NET/LibIpsNet.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public IpsError Create(Stream source, Stream target, ref Stream patch)
240240
while (true)
241241
{
242242
int thisbyte = offset + thislen + consecutiveunchanged;
243-
if (thisbyte < sourcelen && (thisbyte < sourcelen ? Read8(sourceReader, thisbyte) : 0) == Read8(sourceReader, thisbyte)) consecutiveunchanged++;
243+
if (thisbyte < sourcelen && (thisbyte < sourcelen ? Read8(sourceReader, thisbyte) : 0) == Read8(targetReader, thisbyte)) consecutiveunchanged++;
244244
else
245245
{
246246
thislen += consecutiveunchanged + 1;
@@ -365,11 +365,11 @@ public IpsError Create(Stream source, Stream target, ref Stream patch)
365365
}
366366
private byte Read8(BinaryReader reader, int offset = -1)
367367
{
368-
if ((offset > -1) && (offset != reader.BaseStream.Position) && (offset <= reader.BaseStream.Length))
368+
if (offset != -1 && reader.BaseStream.Position != offset)
369369
{
370370
reader.BaseStream.Seek(offset, SeekOrigin.Begin);
371371
}
372-
if (reader.PeekChar() != -1)
372+
if (reader.BaseStream.Position < reader.BaseStream.Length)
373373
{
374374
return reader.ReadByte();
375375
}

0 commit comments

Comments
 (0)