Don't get hrh file timestamps more than once per second
authordadubrow
Mon, 15 Jun 2009 11:00:07 -0500
changeset 249 355219af6139
parent 242 ecdc976d1827
child 250 a2c610d72af3
Don't get hrh file timestamps more than once per second
core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/SymbianBuildContext.java
--- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/SymbianBuildContext.java	Mon Jun 15 08:24:11 2009 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/SymbianBuildContext.java	Mon Jun 15 11:00:07 2009 -0500
@@ -42,6 +42,10 @@
 	// a copy of bad SDK default to fall back
 	private static ISymbianSDK fallbackForBadSdk = SymbianMissingSDKFactory.createInstance("dummy_ID"); //$NON-NLS-1$
 	
+	// last time we checked the hrh file mod dates - only check if changed in last second
+	private static final long HRH_TIMESTAMP_CHECK_QUANTUM = 1000; // 1 sec
+	private static long lastHrhTimestampCheck;
+	
 	private File prefixFileParsed;
 	private List<File> hrhFilesParsed = new ArrayList<File>();
 	private List<IDefine> variantHRHMacros = new ArrayList<IDefine>();
@@ -353,13 +357,15 @@
 			}
 			
 			// now check to see if any of the included hrh files have changed
-			if (!buildCache) {
+			// we will do this at most once per quantum, because it is expensive and during import it was done 100 times per second
+			if (!buildCache && (System.currentTimeMillis() - lastHrhTimestampCheck) > HRH_TIMESTAMP_CHECK_QUANTUM) {
 				for (File file : hrhFilesParsed) {
 					if (file.lastModified() > hrhCacheTimestamp) {
 						buildCache = true;
 						break;
 					}
 				}
+				lastHrhTimestampCheck = System.currentTimeMillis();
 			}
 		}