Skip to content

Commit

Permalink
temporary hack to avoid reading Analysis every compile
Browse files Browse the repository at this point in the history
  • Loading branch information
harrah committed Mar 26, 2011
1 parent dd01209 commit 135609e
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion main/AggressiveCompile.scala
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,19 @@ class AggressiveCompile(cacheDirectory: File)
def javaOnly(f: File) = f.getName.endsWith(".java")

import AnalysisFormats._
val store = AnalysisStore.sync(AnalysisStore.cached(FileBasedStore(cacheDirectory)))
val store = AggressiveCompile.staticCache(cacheDirectory, AnalysisStore.sync(AnalysisStore.cached(FileBasedStore(cacheDirectory))))
}
private object AggressiveCompile
{
import collection.mutable
import java.lang.ref.{Reference,SoftReference}
private[this] val cache = new collection.mutable.HashMap[File, Reference[AnalysisStore]]
private def staticCache(file: File, backing: => AnalysisStore): AnalysisStore =
synchronized {
cache get file flatMap { ref => Option(ref.get) } getOrElse {
val b = backing
cache.put(file, new SoftReference(b))
b
}
}
}

0 comments on commit 135609e

Please sign in to comment.