diff --git a/lcl/lclmemmanager.pas b/lcl/lclmemmanager.pas index ac884d782b..a641a9d986 100644 --- a/lcl/lclmemmanager.pas +++ b/lcl/lclmemmanager.pas @@ -27,7 +27,7 @@ unit LCLMemManager; interface uses - Classes; + Classes, Math; type PLCLMemManagerItem = ^TLCLMemManagerItem; @@ -92,6 +92,8 @@ type { TExtMemoryStream } TExtMemoryStream = class(TMemoryStream) + protected + function Realloc(var NewCapacity: Longint): Pointer; override; public property Capacity: Longint read FCapacity write SetCapacity; end; @@ -267,5 +269,15 @@ begin end; end; +{ TExtMemoryStream } + +function TExtMemoryStream.Realloc(var NewCapacity: LongInt): Pointer; +begin + // if we are growing, grow at least a quarter + if (NewCapacity>Capacity) then + NewCapacity := Max(NewCapacity, Capacity + Capacity div 4); + Result:=inherited Realloc(NewCapacity); +end; + end. diff --git a/lcl/lresources.pp b/lcl/lresources.pp index 67f14367d4..937f89ba90 100644 --- a/lcl/lresources.pp +++ b/lcl/lresources.pp @@ -1933,9 +1933,12 @@ procedure LRSObjectBinaryToText(Input, Output: TStream); procedure ProcessBinary; var - ToDo, DoNow, i: LongInt; + ToDo, DoNow, StartPos, i: LongInt; lbuf: array[0..31] of Byte; s: String; + p: pchar; + const + HexDigits: array[0..$F] of char = '0123456789ABCDEF'; begin ToDo := ReadLRSCardinal(Input); OutLn('{'); @@ -1944,9 +1947,16 @@ procedure LRSObjectBinaryToText(Input, Output: TStream); if DoNow > 32 then DoNow := 32; Dec(ToDo, DoNow); s := Indent + ' '; + StartPos := length(s); Input.Read(lbuf, DoNow); - for i := 0 to DoNow - 1 do - s := s + IntToHex(lbuf[i], 2); + setlength(s, StartPos+DoNow*2); + p := @s[StartPos]; + for i := 0 to DoNow - 1 do begin + inc(p); + p^ := HexDigits[(lbuf[i] shr 4) and $F]; + inc(p); + p^ := HexDigits[lbuf[i] and $F]; + end; OutLn(s); end; OutStr(indent);