Skip to content

Commit

Permalink
Write-back uses unbuffered writer
Browse files Browse the repository at this point in the history
Encoder has 8Kb buffer.
  • Loading branch information
som-snytt committed Jul 8, 2022
1 parent b5e2279 commit 2085bfd
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions compiler/src/dotty/tools/dotc/rewrites/Rewrites.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import collection.mutable
import scala.annotation.tailrec
import dotty.tools.dotc.reporting.Reporter

import java.io.OutputStreamWriter
import java.nio.charset.StandardCharsets.UTF_8

/** Handles rewriting of Scala2 files to Dotty */
Expand Down Expand Up @@ -56,13 +57,11 @@ object Rewrites {
ds
}

def writeBack(): Unit = {
def writeBack(): Unit =
val chars = apply(source.underlying.content)
val bytes = new String(chars).getBytes(UTF_8)
val out = source.file.output
out.write(bytes)
out.close()
}
val osw = OutputStreamWriter(source.file.output, UTF_8)
try osw.write(chars, 0, chars.length)
finally osw.close()
}

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

0 comments on commit 2085bfd

Please sign in to comment.