Skip to content

Commit bf918b2

Browse files
Don't load the whole measurement file into memory at once -- it may be very large
1 parent b41e75e commit bf918b2

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/main/scala/scoverage/IOUtils.scala

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ package scoverage
22

33
import java.io._
44
import scala.xml.{XML, Utility, Node}
5+
import scala.collection.Set
6+
import scala.collection.mutable
7+
import scala.io.Source
58

69
/** @author Stephen Samuel */
710
object IOUtils {
@@ -28,14 +31,18 @@ object IOUtils {
2831
})
2932

3033
// loads all the invoked statement ids from the given files
31-
def invoked(files: Seq[File]): Seq[Int] = {
32-
files.flatMap {
33-
file =>
34-
val reader = new BufferedReader(new FileReader(file))
35-
val line = reader.readLine()
34+
def invoked(files: Seq[File]): Set[Int] = {
35+
val acc = mutable.Set[Int]()
36+
files.foreach { file =>
37+
val reader = Source.fromFile(file)
38+
for (line <- reader.getLines()) {
39+
if (!line.isEmpty) {
40+
acc += line.toInt
41+
}
42+
}
3643
reader.close()
37-
line.split(";").filterNot(_.isEmpty).map(_.toInt)
3844
}
45+
acc
3946
}
4047

4148
/**

src/main/scala/scoverage/Invoker.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ object Invoker {
3131
writer = new FileWriter(file, true)
3232
threadFile.set(writer)
3333
}
34-
writer.append(id.toString + ';').flush()
34+
writer.append(id.toString + '\n').flush()
3535
}
3636
}

0 commit comments

Comments
 (0)