You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Chris Colman <ch...@stepaheadsoftware.com> on 2012/11/24 05:25:11 UTC

WicketTagIdentifier: possible optimization

Just looking at the Wicket source for an unrelated issue I noticed that 
 
WicketTagIdentifier stores a private static collection of
wellKnownTagNames as an ArrayList.
 
and a method called isWellKnown is called from within
WicketTagIdentifier.onComponentTag and presumably it's called on every
Wicket tag parsed.
 
            private boolean isWellKnown(final ComponentTag tag)
            {
                        for (String name : wellKnownTagNames)
                        {
                                    if
(tag.getName().equalsIgnoreCase(name))
                                    {
                                                return true;
                                    }
                        }
                        return false;
            }
 
This method iterates over the list elements until an item is found so
has O(n) performance. If this array list was to be changed to a Set
instead it would have O(1) performance. 
 
I haven't got any metrics on the usage and I don't think the improvement
would be sensational but for web apps with large quantities of markup it
could make some difference. For such a simple change it's probably worth
it.

Re: WicketTagIdentifier: possible optimization

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

Please file a ticket for this improvement.


On Sat, Nov 24, 2012 at 5:25 AM, Chris Colman
<ch...@stepaheadsoftware.com>wrote:

> Just looking at the Wicket source for an unrelated issue I noticed that
>
> WicketTagIdentifier stores a private static collection of
> wellKnownTagNames as an ArrayList.
>
> and a method called isWellKnown is called from within
> WicketTagIdentifier.onComponentTag and presumably it's called on every
> Wicket tag parsed.
>
>             private boolean isWellKnown(final ComponentTag tag)
>             {
>                         for (String name : wellKnownTagNames)
>                         {
>                                     if
> (tag.getName().equalsIgnoreCase(name))
>                                     {
>                                                 return true;
>                                     }
>                         }
>                         return false;
>             }
>
> This method iterates over the list elements until an item is found so
> has O(n) performance. If this array list was to be changed to a Set
> instead it would have O(1) performance.
>
> I haven't got any metrics on the usage and I don't think the improvement
> would be sensational but for web apps with large quantities of markup it
> could make some difference. For such a simple change it's probably worth
> it.
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>