From: Artur Signell Date: Wed, 22 May 2013 14:24:33 +0000 (+0300) Subject: Avoid creating an instance of every view while searching for the correct view (#11722) X-Git-Tag: 7.1.0~90^2~47 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ada3311f7846e812a10547756ce7724f3d4dba6a;p=vaadin-framework.git Avoid creating an instance of every view while searching for the correct view (#11722) Change-Id: Ifab9aa0021bde58280fd75370e5df46fb5efa7a7 --- 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);