I committed some changes to when/how bead lookups work to improve performance. 
Here’s the details:

For the most part, not much has changed from a use-perspective. The only caveat 
is when it comes to models. We had a type check **every** time a bead was added 
to check if it was a model bead and we always tried to load a model bead 
whether it’s needed or not. Needless to say this wasn’t very PAYG. I changed 
models to only be loaded the first time it was actually requested. Since models 
don’t actually dispatch events when loaded this is not a problem. The only 
issue comes up if you use strand.getBeadByType(IBeadModel). This will fail 
because the model was not added yet. strand.getBeadByType(IBeadModel) is 
actually not a great way to get a model int he first place because you’re 
looping through the beads to find the model every time you access it. Since we 
have a model getter, that’s a much better way to get the model. And with the 
new change, it’s kind of necessary to do it that way because the getter will 
load the model if it wasn’t yet loaded.

Sometimes components have more than one model. In that case there’s “the” model 
and other models which is not the main one. It might not be clear to the user 
which is the main model. To solve that issue, there’s now 
getModelByType(strand,type) which returns the model and makjes sure it’s 
initialized if it’s the right type. Otherwise it will find the correct bead and 
return that. When in doubt, always use this function instead of 
strand.getBeadByType.

Views, Controllers and Layouts had a similar issue to models. Not all 
components need a view or a controller or a layout. There’s now a function 
needsView() and needsController() in UIBase. It defaults to true for now 
because I didn’t want to break things, but subclasses can override and change 
it to false. This will prevent the view and controller from being loaded. This 
improves performance on those components. The HTML component set all has this 
set to false.

Similarly, GroupBase now has needsLayout() which also defaults to true and can 
likewise be overridden to return false. Likewise, the HTML component set sets 
this to false.

HTH,
Harbs

Reply via email to