mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
vcs: Refactored "FilePath" implementations not to create new "File" instances on each "getIOFile()" call - reuse same "File" instance created in constructor instead
Otherwise frequent "FilePath.getIOFile()" calls could lead to performance issues. For instance, there are snapshots with slow "Change.isMoved() or Change.isRenamed()" -> "Change.cacheRenameOrMove()" -> "Change.revisionPathsSame()" -> "LocalFilePath.getIOFile()" method calls.
This commit is contained in:
@@ -42,10 +42,12 @@ import java.nio.charset.Charset;
|
||||
@Deprecated
|
||||
public class FilePathImpl implements FilePath {
|
||||
@NotNull private final String myPath;
|
||||
@NotNull private final File myIOFile;
|
||||
private final boolean myIsDirectory;
|
||||
|
||||
public FilePathImpl(@NotNull String path, boolean isDirectory) {
|
||||
myPath = FileUtil.toCanonicalPath(path);
|
||||
myIOFile = new File(myPath);
|
||||
myIsDirectory = isDirectory;
|
||||
}
|
||||
public FilePathImpl(@NotNull VirtualFile file) {
|
||||
@@ -120,7 +122,7 @@ public class FilePathImpl implements FilePath {
|
||||
@Override
|
||||
@NotNull
|
||||
public File getIOFile() {
|
||||
return new File(myPath);
|
||||
return myIOFile;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -35,10 +35,12 @@ import java.nio.charset.Charset;
|
||||
|
||||
public class LocalFilePath implements FilePath {
|
||||
@NotNull private final String myPath;
|
||||
@NotNull private final File myIOFile;
|
||||
private final boolean myIsDirectory;
|
||||
|
||||
public LocalFilePath(@NotNull String path, boolean isDirectory) {
|
||||
myPath = FileUtil.toCanonicalPath(path);
|
||||
myIOFile = new File(myPath);
|
||||
myIsDirectory = isDirectory;
|
||||
}
|
||||
|
||||
@@ -110,7 +112,7 @@ public class LocalFilePath implements FilePath {
|
||||
@Override
|
||||
@NotNull
|
||||
public File getIOFile() {
|
||||
return new File(myPath);
|
||||
return myIOFile;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -37,10 +37,12 @@ public class RemoteFilePath implements FilePath {
|
||||
private static final TObjectHashingStrategy<String> CASE_SENSITIVE_STRATEGY = FilePathHashingStrategy.create(true);
|
||||
|
||||
@NotNull private final String myPath;
|
||||
@NotNull private final File myIOFile;
|
||||
private final boolean myIsDirectory;
|
||||
|
||||
public RemoteFilePath(@NotNull String path, boolean isDirectory) {
|
||||
myPath = path;
|
||||
myIOFile = new File(myPath);
|
||||
myIsDirectory = isDirectory;
|
||||
}
|
||||
|
||||
@@ -59,7 +61,7 @@ public class RemoteFilePath implements FilePath {
|
||||
@NotNull
|
||||
@Override
|
||||
public File getIOFile() {
|
||||
return new File(myPath);
|
||||
return myIOFile;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user