From ada3311f7846e812a10547756ce7724f3d4dba6a Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 22 May 2013 17:24:33 +0300 Subject: [PATCH] Avoid creating an instance of every view while searching for the correct view (#11722) Change-Id: Ifab9aa0021bde58280fd75370e5df46fb5efa7a7 --- server/src/com/vaadin/navigator/Navigator.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/server/src/com/vaadin/navigator/Navigator.java b/server/src/com/vaadin/navigator/Navigator.java index df05a9fbce..540a3ee302 100644 --- a/server/src/com/vaadin/navigator/Navigator.java +++ b/server/src/com/vaadin/navigator/Navigator.java @@ -497,19 +497,22 @@ public class Navigator implements Serializable { */ public void navigateTo(String navigationState) { String longestViewName = null; + ViewProvider longestViewNameProvider = null; View viewWithLongestName = null; for (ViewProvider provider : providers) { String viewName = provider.getViewName(navigationState); if (null != viewName && (longestViewName == null || viewName.length() > longestViewName .length())) { - View view = provider.getView(viewName); - if (null != view) { - longestViewName = viewName; - viewWithLongestName = view; - } + longestViewName = viewName; + longestViewNameProvider = provider; } } + if (longestViewName != null) { + viewWithLongestName = longestViewNameProvider + .getView(longestViewName); + } + if (viewWithLongestName == null && errorProvider != null) { longestViewName = errorProvider.getViewName(navigationState); viewWithLongestName = errorProvider.getView(longestViewName); -- 2.39.5