Einzelnen Beitrag anzeigen

Der schöne Günther

Registriert seit: 6. Mär 2013
6.176 Beiträge
 
Delphi 10 Seattle Enterprise
 
#12

AW: Generics - Pro und Contra

  Alt 24. Mai 2014, 10:21
Ich habe mich damit nie befasst, aber soweit ich es verstanden habe erzeugt folgendes einmal Code für eine Integer-Liste und einmal Code für eine TObject-Liste:

Delphi-Quellcode:
var
   myIntegerList: TList<Integer>;
   myObjectList: TList<TObject>;
Stevie hat da neulich nochmal zu geschrieben:
Zitat:
This by the way is one of the reasons your empty default applications are growing constantly for the recent releases of Delphi: because now generic collections are used all over the place in the runtime. And when I use TList<TButton>, boom, another 10K added to your binary size (approx in XE5). Too bad if you are using more advanced and feature rich collection types like Spring4D. Then every use adds 65K (actually we got down to that number from close to 100K a few months ago).

How could this be solved? Either by the linker fixing this by figuring out identical methods and removing duplicates (the C++ linker has an option for that called COMDAT folding) or the compiler itself could be smart and generate code for equal types only once. Of course he should pay attention to any use of TypeInfo(T) or T.Create for example because that code is actually different. C# does something like this.
Quelle: Delphi Sorcery
  Mit Zitat antworten Zitat