Skip to content

Commit 06ffc8c

Browse files
authored
Bring back windows performance improvements (#20423)
Previously reverted due to conflicts on main just before 3.5.0 cutoff. Original PR by @OlegYch (#20193). I added an additional commit fixing the issues (like in #20358)
2 parents c608177 + c6086f6 commit 06ffc8c

File tree

7 files changed

+4
-35
lines changed

7 files changed

+4
-35
lines changed

Diff for: compiler/src/dotty/tools/dotc/core/tasty/BestEffortTastyWriter.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ object BestEffortTastyWriter:
1818
unit.pickled.foreach { (clz, binary) =>
1919
val parts = clz.fullName.mangledString.split('.')
2020
val outPath = outputPath(parts.toList, dir)
21-
val outTastyFile = new PlainFile(new File(outPath))
22-
val outstream = new DataOutputStream(outTastyFile.bufferedOutput)
21+
val outTastyFile = new File(outPath)
22+
val outstream = new DataOutputStream(new PlainFile(outTastyFile).bufferedOutput)
2323
try outstream.write(binary())
2424
catch case ex: ClosedByInterruptException =>
2525
try

Diff for: compiler/src/dotty/tools/io/AbstractFile.scala

-6
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,6 @@ abstract class AbstractFile extends Iterable[AbstractFile] {
136136
/** Does this abstract file represent something which can contain classfiles? */
137137
def isClassContainer: Boolean = isDirectory || (jpath != null && ext.isJarOrZip)
138138

139-
/** Create a file on disk, if one does not exist already. */
140-
def create(): Unit
141-
142-
/** Delete the underlying file or directory (recursively). */
143-
def delete(): Unit
144-
145139
/** Is this abstract file a directory? */
146140
def isDirectory: Boolean
147141

Diff for: compiler/src/dotty/tools/io/NoAbstractFile.scala

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ import java.io.InputStream
1717
object NoAbstractFile extends AbstractFile {
1818
def absolute: AbstractFile = this
1919
def container: AbstractFile = this
20-
def create(): Unit = ???
21-
def delete(): Unit = ???
2220
def jpath: JPath = null
2321
def input: InputStream = null
2422
def isDirectory: Boolean = false

Diff for: compiler/src/dotty/tools/io/PlainFile.scala

+2-11
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ import java.nio.file.{InvalidPathException, Paths}
1313

1414
/** ''Note: This library is considered experimental and should not be used unless you know what you are doing.'' */
1515
class PlainDirectory(givenPath: Directory) extends PlainFile(givenPath) {
16-
override def isDirectory: Boolean = true
16+
override val isDirectory: Boolean = true
1717
override def iterator(): Iterator[PlainFile] = givenPath.list.filter(_.exists).map(new PlainFile(_))
18-
override def delete(): Unit = givenPath.deleteRecursively()
1918
}
2019

2120
/** This class implements an abstract file backed by a File.
@@ -78,7 +77,7 @@ class PlainFile(val givenPath: Path) extends AbstractFile {
7877
}
7978

8079
/** Is this abstract file a directory? */
81-
def isDirectory: Boolean = givenPath.isDirectory
80+
val isDirectory: Boolean = givenPath.isDirectory // cached for performance on Windows
8281

8382
/** Returns the time that this abstract file was last modified. */
8483
def lastModified: Long = givenPath.lastModified.toMillis
@@ -113,14 +112,6 @@ class PlainFile(val givenPath: Path) extends AbstractFile {
113112
null
114113
}
115114

116-
/** Does this abstract file denote an existing file? */
117-
def create(): Unit = if (!exists) givenPath.createFile()
118-
119-
/** Delete the underlying file or directory (recursively). */
120-
def delete(): Unit =
121-
if (givenPath.isFile) givenPath.delete()
122-
else if (givenPath.isDirectory) givenPath.toDirectory.deleteRecursively()
123-
124115
/** Returns a plain file with the given name. It does not
125116
* check that it exists.
126117
*/

Diff for: compiler/src/dotty/tools/io/VirtualDirectory.scala

-6
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@ extends AbstractFile {
3434
override def input: InputStream = sys.error("directories cannot be read")
3535
override def output: OutputStream = sys.error("directories cannot be written")
3636

37-
/** Does this abstract file denote an existing file? */
38-
def create(): Unit = { unsupported() }
39-
40-
/** Delete the underlying file or directory (recursively). */
41-
def delete(): Unit = { unsupported() }
42-
4337
/** Returns an abstract file with the given name. It does not
4438
* check that it exists.
4539
*/

Diff for: compiler/src/dotty/tools/io/VirtualFile.scala

-6
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,6 @@ class VirtualFile(val name: String, override val path: String) extends AbstractF
8282
Iterator.empty
8383
}
8484

85-
/** Does this abstract file denote an existing file? */
86-
def create(): Unit = unsupported()
87-
88-
/** Delete the underlying file or directory (recursively). */
89-
def delete(): Unit = unsupported()
90-
9185
/**
9286
* Returns the abstract file in this abstract directory with the
9387
* specified name. If there is no such file, returns null. The

Diff for: compiler/src/dotty/tools/io/ZipArchive.scala

-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ abstract class ZipArchive(override val jpath: JPath, release: Option[String]) ex
6161
def isDirectory: Boolean = true
6262
def lookupName(name: String, directory: Boolean): AbstractFile = unsupported()
6363
def lookupNameUnchecked(name: String, directory: Boolean): AbstractFile = unsupported()
64-
def create(): Unit = unsupported()
65-
def delete(): Unit = unsupported()
6664
def output: OutputStream = unsupported()
6765
def container: AbstractFile = unsupported()
6866
def absolute: AbstractFile = unsupported()

0 commit comments

Comments
 (0)