Eliminated redundant invocations of HandlerCollection.getHandlers()

Signed-off-by: Matthias Perktold <tias251@gmail.com>
This commit is contained in:
Matthias Perktold 2018-06-18 19:13:10 +02:00
parent f7df6b3326
commit 09f614b48e
2 changed files with 7 additions and 5 deletions

View File

@ -85,7 +85,8 @@ public class ContextHandlerCollection extends HandlerCollection
{
_contextBranches.clear();
if (getHandlers()==null)
Handler[] handlers = getHandlers();
if (handlers==null)
{
_pathBranches=new ArrayTernaryTrie<>(false,16);
return;
@ -93,7 +94,7 @@ public class ContextHandlerCollection extends HandlerCollection
// Create map of contextPath to handler Branch
Map<String,Branch[]> map = new HashMap<>();
for (Handler handler:getHandlers())
for (Handler handler:handlers)
{
Branch branch=new Branch(handler);
for (String contextPath : branch.getContextPaths())

View File

@ -184,8 +184,9 @@ public class HandlerCollection extends AbstractHandlerContainer
@Override
protected void expandChildren(List<Handler> list, Class<?> byClass)
{
if (getHandlers()!=null)
for (Handler h:getHandlers())
Handler[] handlers = getHandlers();
if (handlers!=null)
for (Handler h:handlers)
expandHandler(h, list, byClass);
}
@ -207,6 +208,6 @@ public class HandlerCollection extends AbstractHandlerContainer
public String toString()
{
Handler[] handlers=getHandlers();
return super.toString()+(handlers==null?"[]":Arrays.asList(getHandlers()).toString());
return super.toString()+(handlers==null?"[]":Arrays.asList(handlers).toString());
}
}