I was stepping through the wicket code trying to track down a problem
with my page when I ran across some code. In
MarkupContainer.children_add() there's this code:
if (this.children == null)
{
this.children = child;
}
else
{
// Get current list size
final int size = children_size();
// Create array that holds size + 1 elements
final Component[] children = new Component[size + 1];
// Loop through existing children copying them
for (int i = 0; i < size; i++)
{
children[i] = children_get(i);
}
// Add new child to the end
children[size] = child;
// Save new children
this.children = children;
}
It's look to me like a great case for System.arraycopy(). Now, i'm not
all that familiar with the code so maybe there's a good reason for this,
but I don't think i've ever seen a loop like this outperform
System.arraycopy(). And perhaps it could use a List or a Set rather
than an array since many of the operations are already provided.
Likewise children_get() does full array scans looking for an item by ID
when using a map would give much better performance. But perhaps it was
decided that the lists would likely be small enough not to matter. But
I can see this kind of thing adding up to some significant time in some
cases. Maybe there are some good decisions behind this code, but it
doesn't appear to be documented anywhere.
Anyway, not to nit pick, I just saw that code and had to bring it up.
--
Justin Lee
http://www.antwerkz.com
AIM : evan chooly
720.299.0101
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user