El 08/09/2017 a las 10:34, Bo Berglund escribió:

   for i := 0 to l-1 do
   begin
     sLine := sLine + IntToHex(Buf[i],2);
   end;
   lbxLog.Items.Add(sTime + ' ' + sLine);
   lbxLog.ItemIndex := lbxLog.Items.Count-1;

Hello,

This is a big "NO, NO!" for quite large buffers, that code can take a lot of time for a 50K buffer, as it will render in the expected 50K inttohex conversions, but also (in worst and impossible case scenario) 50K memory moves, 50K thread locks, 50K memory allocations and 50K memory frees.

Much better something like:

SetLength(sLine, Length(buf) * 2);
Bin2Hex(@Buf[0],sLine[1],Length(Buf));
sLine := Prefix + ':' + sLine;

Please recheck params syntax for Bin2Hex, my memory is not as it used to be :-)

A large listbox is not also very good.

--

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to