Skip to content

Commit

Permalink
Editor: simplified Utilities.CopyStream()
Browse files Browse the repository at this point in the history
The extra checks present in C++ variant could be overkill when using .NET classes.
  • Loading branch information
ivan-mogilko committed Aug 22, 2023
1 parent aa66c08 commit ae42796
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions Editor/AGS.Editor/Utils/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,17 +330,8 @@ public static long CopyStream(Stream instream, Stream outstream, long length)
if (wasRead == 0)
return wroteTotal;
length -= wasRead;
int toWrite = wasRead;
while (toWrite > 0)
{
long oldPos = outstream.Position;
outstream.Write(buf, wasRead - toWrite, toWrite);
int wrote = (int)(outstream.Position - oldPos);
if (wrote == 0)
return wroteTotal;
toWrite -= wrote;
wroteTotal += wrote;
}
outstream.Write(buf, 0, wasRead);
wroteTotal += wasRead;
}
return wroteTotal;
}
Expand Down

0 comments on commit ae42796

Please sign in to comment.