Einzelnen Beitrag anzeigen

Aviator

Registriert seit: 3. Jun 2010
1.611 Beiträge
 
Delphi 10.3 Rio
 
#32

AW: Datenhaltung mit VirtualStringTree und Trennung der Businesslogik

  Alt 1. Apr 2019, 20:52
Davon würde ich gerne mehr erfahren wollen? Also der Grund, warum man nicht AddChild verwenden soll, ist nur die Performance oder gibt es noch andere Gründe? Gab es Performancetests dazu?
Ein Grund ist sicherlich die Performance. Der Tree initialisiert gewisse Dinge erst dann, wenn sie benötigt werden. Und das passiert nur, wenn RootNodeCount bzw. ChildCount benutzt wird. Bei AddChild hingegen wird die Node direkt initialisiert. Zudem ist es mit RootNodeCount soweit ich weiß auch möglich, die NodeDaten erst dynamisch und zu dem Zeitpunkt zu laden an dem sie benötigt werden (eben virtuell).

Zum Schluss noch ein kleiner Auszug aus dem VirtualTreeView SourceCode zur AddChild() Methode.

Zitat von VirtualTreeView:
// Adds a new node to the given parent node. This is simply done by increasing the child count of the
// parent node. If Parent is nil then the new node is added as (last) top level node.
// UserData can be used to set the first SizeOf(Pointer) bytes of the user data area to an initial value which can be used
// in OnInitNode and will also cause to trigger the OnFreeNode event (if <> nil) even if the node is not yet
// "officially" initialized.
// AddChild is a compatibility method and will implicitly validate the parent node. This is however
// against the virtual paradigm and hence I dissuade from its usage.
  Mit Zitat antworten Zitat