summaryrefslogtreecommitdiff
path: root/src/reflect/scala/tools/nsc/io/ZipArchive.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-09-13 07:03:17 -0700
committerPaul Phillips <paulp@improving.org>2012-09-14 11:12:22 -0700
commit47587dca4d3fb7c171cff21587b42f40bab77e21 (patch)
tree4da603fb0bf26a8670bc5567e0c4ae91ef85d516 /src/reflect/scala/tools/nsc/io/ZipArchive.scala
parent9d84e89d27c396203e84f6ae685863210ebc1968 (diff)
downloadscala-47587dca4d3fb7c171cff21587b42f40bab77e21.tar.gz
scala-47587dca4d3fb7c171cff21587b42f40bab77e21.tar.bz2
scala-47587dca4d3fb7c171cff21587b42f40bab77e21.zip
Optimization in ZipArchive.
There's that empty array. When compiling "trait Foo", this took me from allocating 44,410 empty arrays to allocating 383 of them.
Diffstat (limited to 'src/reflect/scala/tools/nsc/io/ZipArchive.scala')
-rw-r--r--src/reflect/scala/tools/nsc/io/ZipArchive.scala6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/reflect/scala/tools/nsc/io/ZipArchive.scala b/src/reflect/scala/tools/nsc/io/ZipArchive.scala
index d1a91294a5..8201059ca0 100644
--- a/src/reflect/scala/tools/nsc/io/ZipArchive.scala
+++ b/src/reflect/scala/tools/nsc/io/ZipArchive.scala
@@ -107,14 +107,14 @@ abstract class ZipArchive(override val file: JFile) extends AbstractFile with Eq
// })
dirs get path match {
case Some(v) => v
- case None =>
+ case None =>
val parent = ensureDir(dirs, dirName(path), null)
val dir = new DirEntry(path)
parent.entries(baseName(path)) = dir
dirs(path) = dir
dir
}
-
+
protected def getDir(dirs: mutable.Map[String, DirEntry], entry: ZipEntry): DirEntry = {
if (entry.isDirectory) ensureDir(dirs, entry.getName, entry)
else ensureDir(dirs, dirName(entry.getName), null)
@@ -177,7 +177,7 @@ final class URLZipArchive(val url: URL) extends ZipArchive(null) {
class FileEntry() extends Entry(zipEntry.getName) {
override val toByteArray: Array[Byte] = {
val len = zipEntry.getSize().toInt
- val arr = new Array[Byte](len)
+ val arr = if (len == 0) Byte.emptyArray else new Array[Byte](len)
var offset = 0
def loop() {