GWT.getModuleBaseURL() should be fast.. really fast. Currently, it's not. This patch makes it fast.
Review by: knorton
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@578 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/shell/HostedModeSourceOracle.java b/dev/core/src/com/google/gwt/dev/shell/HostedModeSourceOracle.java
index 9e79588..10d0a77 100644
--- a/dev/core/src/com/google/gwt/dev/shell/HostedModeSourceOracle.java
+++ b/dev/core/src/com/google/gwt/dev/shell/HostedModeSourceOracle.java
@@ -41,6 +41,8 @@
sb.append(" void onUncaughtException(Throwable e);\n");
sb.append(" }\n");
+ sb.append(" private static String sModuleBaseURL = null;\n");
+
// Hosted mode default to logging
//
sb.append(" private static UncaughtExceptionHandler sUncaughtExceptionHandler = \n");
@@ -97,7 +99,10 @@
// Proxy getModuleBaseURL() to the Impl class.
//
sb.append(" public static String getModuleBaseURL() {\n");
- sb.append(" return Impl.getModuleBaseURL();\n");
+ sb.append(" if (sModuleBaseURL == null) {\n");
+ sb.append(" sModuleBaseURL = Impl.getModuleBaseURL();\n");
+ sb.append(" }\n");
+ sb.append(" return sModuleBaseURL;\n");
sb.append(" }\n");
// Proxy log().
diff --git a/user/src/com/google/gwt/core/client/GWT.java b/user/src/com/google/gwt/core/client/GWT.java
index 0aa39a4..ba05ac4 100644
--- a/user/src/com/google/gwt/core/client/GWT.java
+++ b/user/src/com/google/gwt/core/client/GWT.java
@@ -35,6 +35,9 @@
void onUncaughtException(Throwable e);
}
+ // cache of the module base URL
+ private static String sModuleBaseURL = null;
+
// web mode default is to let the exception go
// hosted mode default is to log the exception to the log window
private static UncaughtExceptionHandler sUncaughtExceptionHandler = null;
@@ -74,7 +77,10 @@
* @return if non-empty, the base URL is guaranteed to end with a slash
*/
public static String getModuleBaseURL() {
- return Impl.getModuleBaseURL();
+ if (sModuleBaseURL == null) {
+ sModuleBaseURL = Impl.getModuleBaseURL();
+ }
+ return sModuleBaseURL;
}
/**