summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/classpath
diff options
context:
space:
mode:
authormpociecha <michal.pociecha@gmail.com>2014-11-30 23:08:10 +0100
committermpociecha <michal.pociecha@gmail.com>2014-12-05 01:21:04 +0100
commitdfc5c1d7225163994e3bc1cf67ccbee8c4de75fc (patch)
treee3a670ad49afba61837ae747ed378606407a0129 /src/compiler/scala/tools/nsc/classpath
parent04620a0e2a0cf64f2d33e32007d85afabad5e201 (diff)
downloadscala-dfc5c1d7225163994e3bc1cf67ccbee8c4de75fc.tar.gz
scala-dfc5c1d7225163994e3bc1cf67ccbee8c4de75fc.tar.bz2
scala-dfc5c1d7225163994e3bc1cf67ccbee8c4de75fc.zip
Create possibility to skip flat classpath caching
There's added -YdisableFlatCpCaching option to ScalaSettings which allows user to disable caching of flat representation of classpath elements.
Diffstat (limited to 'src/compiler/scala/tools/nsc/classpath')
-rw-r--r--src/compiler/scala/tools/nsc/classpath/ZipAndJarFileLookupFactory.scala13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/classpath/ZipAndJarFileLookupFactory.scala b/src/compiler/scala/tools/nsc/classpath/ZipAndJarFileLookupFactory.scala
index 6d8c4880d5..dba3c60b0f 100644
--- a/src/compiler/scala/tools/nsc/classpath/ZipAndJarFileLookupFactory.scala
+++ b/src/compiler/scala/tools/nsc/classpath/ZipAndJarFileLookupFactory.scala
@@ -11,7 +11,7 @@ import scala.tools.nsc.Settings
import FileUtils._
/**
- * A trait providing a cache for classpath entries obtained from zip and jar files.
+ * A trait providing an optional cache for classpath entries obtained from zip and jar files.
* It's possible to create such a cache assuming that entries in such files won't change (at
* least will be the same each time we'll load classpath during the lifetime of JVM process)
* - unlike class and source files in directories, which can be modified and recompiled.
@@ -22,7 +22,14 @@ trait ZipAndJarFileLookupFactory {
private val cache = collection.mutable.Map.empty[AbstractFile, FlatClassPath]
- def create(zipFile: AbstractFile, settings: Settings): FlatClassPath = cache.synchronized {
+ def create(zipFile: AbstractFile, settings: Settings): FlatClassPath = {
+ if (settings.YdisableFlatCpCaching) createForZipFile(zipFile)
+ else createUsingCache(zipFile, settings)
+ }
+
+ protected def createForZipFile(zipFile: AbstractFile): FlatClassPath
+
+ private def createUsingCache(zipFile: AbstractFile, settings: Settings): FlatClassPath = cache.synchronized {
def newClassPathInstance = {
if (settings.verbose || settings.Ylogcp)
println(s"$zipFile is not yet in the classpath cache")
@@ -30,8 +37,6 @@ trait ZipAndJarFileLookupFactory {
}
cache.getOrElseUpdate(zipFile, newClassPathInstance)
}
-
- protected def createForZipFile(zipFile: AbstractFile): FlatClassPath
}
/**