|
@@ -372,23 +372,22 @@ end;
|
|
|
|
|
|
procedure TStreamWriter.WriteBytes(Bytes: TBytes);
|
|
procedure TStreamWriter.WriteBytes(Bytes: TBytes);
|
|
var
|
|
var
|
|
- ByteLen,Count,WritePos,ToWrite: Integer;
|
|
|
|
|
|
+ BufLen,Count,ToWrite: Integer;
|
|
P : PByte;
|
|
P : PByte;
|
|
begin
|
|
begin
|
|
- ByteLen:=Length(Bytes);
|
|
|
|
- ToWrite:=ByteLen;
|
|
|
|
- WritePos:=0;
|
|
|
|
|
|
+ BufLen:=Length(FBuffer);
|
|
|
|
+ ToWrite:=Length(Bytes);
|
|
P:=PByte(Bytes);
|
|
P:=PByte(Bytes);
|
|
while ToWrite>0 do
|
|
while ToWrite>0 do
|
|
begin
|
|
begin
|
|
Count:=ToWrite;
|
|
Count:=ToWrite;
|
|
- if Count>ByteLen-WritePos then
|
|
|
|
- Count:=ByteLen-WritePos;
|
|
|
|
- Move(P^, FBuffer[FBufferIndex], Count);
|
|
|
|
- Inc(WritePos,Count);
|
|
|
|
|
|
+ if Count>BufLen-FBufferIndex then
|
|
|
|
+ Count:=BufLen-FBufferIndex;
|
|
|
|
+ Move(P^,FBuffer[FBufferIndex],Count);
|
|
Inc(P,Count);
|
|
Inc(P,Count);
|
|
Dec(ToWrite,Count);
|
|
Dec(ToWrite,Count);
|
|
- if FBufferIndex >= Length(FBuffer) then
|
|
|
|
|
|
+ Inc(FBufferIndex,Count);
|
|
|
|
+ if FBufferIndex>=BufLen then
|
|
Flush;
|
|
Flush;
|
|
end;
|
|
end;
|
|
if FAutoFlush then
|
|
if FAutoFlush then
|