View Issue Details

IDProjectCategoryView StatusLast Update
0036270FPCRTLpublic2019-11-09 12:16
ReporterAlexey Tor.Assigned To 
Status newResolutionopen 
Product Version3.3.1Product Build 
Target VersionFixed in Version 
Summary0036270: TFPSList.Assign and .AddList can be faster

procedure TFPSList.AddList(Obj: TFPSList);
  i: Integer;
  if Obj.ItemSize <> FItemSize then
    Error(SListItemSizeError, 0);
  for I := 0 to Obj.Count - 1 do

Assign() calls Clear then AddList, it's not fast.
But it can be super fast:
- realloc FList to needed size
- Move() data to FList

I need super-fast TFPSList.Assign, pls change it.
TagsNo tags attached.
Fixed in Revision
Attached Files


Michael Van Canneyt

2019-11-06 11:58

administrator   ~0119097

I don't think a move is correct.
For simple things as an integer, or a class pointer, this will work. But sometimes there are things to be taken into account such as ref. counting when strings are involved, or interfaces.

I'm not an expert, but I think the best that can be done is to set the capacity prior to doing the loop.

Ugochukwu Mmaduekwe

2019-11-06 19:14

reporter   ~0119109

Last edited: 2019-11-06 19:18

View 4 revisions

@micheal, you are right.
Using Move on data types like strings and interfaces will surely break reference counting.
This is one of the many places where intrinsic compiler functions such as
function IsManagedType(T: TypeIdentifier): Boolean;
suggested here will come in handy. 😁
If available, we would use it to perform a check which the compiler can determine during compile time and use it to produce optimal code.

Thaddy de Koning

2019-11-09 12:16

reporter   ~0119173

IsManagedType is in latest trunk, Sven added it this week.

Issue History

Date Modified Username Field Change
2019-11-06 11:41 Alexey Tor. New Issue
2019-11-06 11:58 Michael Van Canneyt Note Added: 0119097
2019-11-06 19:14 Ugochukwu Mmaduekwe Note Added: 0119109
2019-11-06 19:15 Ugochukwu Mmaduekwe Note Edited: 0119109 View Revisions
2019-11-06 19:15 Ugochukwu Mmaduekwe Note Edited: 0119109 View Revisions
2019-11-06 19:18 Ugochukwu Mmaduekwe Note Edited: 0119109 View Revisions
2019-11-09 12:16 Thaddy de Koning Note Added: 0119173