]> source.dussan.org Git - vaadin-framework.git/commitdiff
Avoid creating an instance of every view while searching for the correct view (#11722)
authorArtur Signell <artur@vaadin.com>
Wed, 22 May 2013 14:24:33 +0000 (17:24 +0300)
committerArtur Signell <artur@vaadin.com>
Thu, 23 May 2013 06:40:22 +0000 (09:40 +0300)
Change-Id: Ifab9aa0021bde58280fd75370e5df46fb5efa7a7

server/src/com/vaadin/navigator/Navigator.java

index df05a9fbce5e27a61be930b5db195fd8bc8d0c1b..540a3ee30261740bc9f2e18179cc62c635e8f7d8 100644 (file)
@@ -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);