8
votes
Vote UpVote

Delphi array constructors performance (or lack of)

DelphiTools – In Delphi you can initialize a dynamic array in two ways, either manually or via the Create magic constructor: type TIntegerArray = array of Integer; procedure Test; var a : TIntegerArray; begin // magic constructor a := TIntegerArray.Create(1, 2); // manual creation SetLength(a, 2); a[0] := 1; a[1] := 2; end; The outcome in both cases is the same, are all things equal? Some array initializations are more equal than others The first method is less verbose in code, but quite a bit less efficient, if you check the CPU view, that becomes obvious TestUnit.pas.32: a := ...
Favorite? Off-Topic? Eric @ 2013-02-18 08:29

Statistics

Visits: 1160
Votes: 8
Favorites: 0
Off-Topic: 0

Visits by Source

User Actions

Users who voted for this posting

Ericc
François
Jordi Coll Corbilla
Jørn E. Angeltveit
knight_killer
Radosław Kokoć
runner
Zzzzz
Subscribe:
Contact us to advertise on DelphiFeeds.com

Community Links

Torry Firebird News

Sponsor

 
Please login or register to use this functionality.
(click on this box to dismiss)