Skip to content

Commit 2085bfd

Browse files
committed
Write-back uses unbuffered writer
Encoder has 8Kb buffer.
1 parent b5e2279 commit 2085bfd

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

compiler/src/dotty/tools/dotc/rewrites/Rewrites.scala

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import collection.mutable
88
import scala.annotation.tailrec
99
import dotty.tools.dotc.reporting.Reporter
1010

11+
import java.io.OutputStreamWriter
1112
import java.nio.charset.StandardCharsets.UTF_8
1213

1314
/** Handles rewriting of Scala2 files to Dotty */
@@ -56,13 +57,11 @@ object Rewrites {
5657
ds
5758
}
5859

59-
def writeBack(): Unit = {
60+
def writeBack(): Unit =
6061
val chars = apply(source.underlying.content)
61-
val bytes = new String(chars).getBytes(UTF_8)
62-
val out = source.file.output
63-
out.write(bytes)
64-
out.close()
65-
}
62+
val osw = OutputStreamWriter(source.file.output, UTF_8)
63+
try osw.write(chars, 0, chars.length)
64+
finally osw.close()
6665
}
6766

6867
/** If -rewrite is set, record a patch that replaces the range

0 commit comments

Comments
 (0)