diff options
author | Paolo G. Giarrusso <p.giarrusso@gmail.com> | 2014-02-15 10:47:28 +0100 |
---|---|---|
committer | Paolo G. Giarrusso <p.giarrusso@gmail.com> | 2014-02-16 16:34:02 +0100 |
commit | 8161b51548105c5d30df7564526f7dc7a5cf2ac9 (patch) | |
tree | 572841f04baa0b7cdc9895dbcd928f125fcf1bf4 | |
parent | f59aeb58681d1dba8d32886de4785f6fb8dc9eff (diff) | |
download | scala-8161b51548105c5d30df7564526f7dc7a5cf2ac9.tar.gz scala-8161b51548105c5d30df7564526f7dc7a5cf2ac9.tar.bz2 scala-8161b51548105c5d30df7564526f7dc7a5cf2ac9.zip |
Avoid storing source file contents twice
BatchSourceFile instances contain two almost identical character arrays,
content0 and content. What's worse, content0 is even public. Instead,
content0 should just be a constructor parameter. This seems the residual
of an incomplete refactoring.
I observed this waste of memory during debugging; after applying this
patch, I've verified by hand that the second field indeed disappears.
I don't expect a measurable difference, but this patch is not premature
optimization because it makes code more logical.
-rw-r--r-- | src/reflect/scala/reflect/internal/util/SourceFile.scala | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/reflect/scala/reflect/internal/util/SourceFile.scala b/src/reflect/scala/reflect/internal/util/SourceFile.scala index 8791d8eb23..4fccad74ac 100644 --- a/src/reflect/scala/reflect/internal/util/SourceFile.scala +++ b/src/reflect/scala/reflect/internal/util/SourceFile.scala @@ -107,7 +107,7 @@ class ScriptSourceFile(underlying: BatchSourceFile, content: Array[Char], overri } /** a file whose contents do not change over time */ -class BatchSourceFile(val file : AbstractFile, val content0: Array[Char]) extends SourceFile { +class BatchSourceFile(val file : AbstractFile, content0: Array[Char]) extends SourceFile { def this(_file: AbstractFile) = this(_file, _file.toCharArray) def this(sourceName: String, cs: Seq[Char]) = this(new VirtualFile(sourceName), cs.toArray) def this(file: AbstractFile, cs: Seq[Char]) = this(file, cs.toArray) |