diff options
author | Paul Phillips <paulp@improving.org> | 2010-01-15 19:48:57 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-01-15 19:48:57 +0000 |
commit | 74c615c83567c930ce371833ff4b275312a4540f (patch) | |
tree | 99c75dbfffcb07c354716286f381b12b57b3e649 /src | |
parent | 9bd9b9fcc1623ca3b6c98cb7ce12f31581750372 (diff) | |
download | scala-74c615c83567c930ce371833ff4b275312a4540f.tar.gz scala-74c615c83567c930ce371833ff4b275312a4540f.tar.bz2 scala-74c615c83567c930ce371833ff4b275312a4540f.zip |
Wrapped a buffered output stream around class f...
Wrapped a buffered output stream around class file generation. This has
a nontrivial impact on total build time. Closes #2906.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala | 8 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/dependencies/Files.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/io/AbstractFile.scala | 5 |
3 files changed, 8 insertions, 7 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala index 50e16dc6b8..d622edc8ab 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -8,7 +8,7 @@ package scala.tools.nsc package backend.jvm -import java.io.{DataOutputStream, File, OutputStream} +import java.io.{ DataOutputStream, File, OutputStream } import java.nio.ByteBuffer import scala.collection.immutable.{Set, ListSet} @@ -145,7 +145,7 @@ abstract class GenJVM extends SubComponent { addInnerClasses(jclass) val outfile = getFile(sym, jclass, ".class") - val outstream = new DataOutputStream(outfile.output) + val outstream = new DataOutputStream(outfile.bufferedOutput) jclass.writeTo(outstream) outstream.close() informProgress("wrote " + outfile) @@ -314,7 +314,7 @@ abstract class GenJVM extends SubComponent { // write the bean information class file. val outfile = getFile(c.symbol, beanInfoClass, ".class") - val outstream = new DataOutputStream(outfile.output) + val outstream = new DataOutputStream(outfile.bufferedOutput) beanInfoClass.writeTo(outstream) outstream.close() informProgress("wrote BeanInfo " + outfile) @@ -1820,8 +1820,6 @@ abstract class GenJVM extends SubComponent { dir.fileNamed(pathParts.last + suffix) } - - /** Merge adjacent ranges. */ private def mergeEntries(ranges: List[(Int, Int)]): List[(Int, Int)] = (ranges.foldLeft(Nil: List[(Int, Int)]) { (collapsed: List[(Int, Int)], p: (Int, Int)) => (collapsed, p) match { diff --git a/src/compiler/scala/tools/nsc/dependencies/Files.scala b/src/compiler/scala/tools/nsc/dependencies/Files.scala index 2165855ac9..09f694b6ca 100644 --- a/src/compiler/scala/tools/nsc/dependencies/Files.scala +++ b/src/compiler/scala/tools/nsc/dependencies/Files.scala @@ -150,7 +150,7 @@ trait Files { self : SubComponent => } def writeToFile[T](file: AbstractFile)(f: OutputStream => T) : T = { - val out = file.output + val out = file.bufferedOutput try { f(out) } finally { diff --git a/src/compiler/scala/tools/nsc/io/AbstractFile.scala b/src/compiler/scala/tools/nsc/io/AbstractFile.scala index 82116f3ca2..31073a0799 100644 --- a/src/compiler/scala/tools/nsc/io/AbstractFile.scala +++ b/src/compiler/scala/tools/nsc/io/AbstractFile.scala @@ -8,7 +8,7 @@ package scala.tools.nsc package io -import java.io.{ File => JFile, FileOutputStream, IOException, InputStream, OutputStream } +import java.io.{ File => JFile, FileOutputStream, IOException, InputStream, OutputStream, BufferedOutputStream } import java.net.URL import PartialFunction._ @@ -126,6 +126,9 @@ abstract class AbstractFile extends AnyRef with Iterable[AbstractFile] { /** Returns an output stream for writing the file */ def output: OutputStream + /** Returns an unbuffered output stream for writing the file - defaults to out */ + def bufferedOutput: BufferedOutputStream = new BufferedOutputStream(output) + /** size of this file if it is a concrete file. */ def sizeOption: Option[Int] = None |