Merge pull request #2674 from mperktold/jetty-9.4.x

Eliminated redundant invocations of HandlerCollection.getHandlers()
This commit is contained in:
Greg Wilkins 2018-06-19 08:58:28 +02:00 committed by GitHub
commit 5e1db95282
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

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

View File

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