mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[vcs] Don't wrap FilePath creation into read action
There is no point in this read action, but it takes the lock => may slow down if the utility method is used during a large VCS process (even if taken atomically). VCS requires file content rarely, so the only benefit from this read was in the situation, if a VirtualFile gets created when we've already went to createForDeletedFile (and similar situations). However, it is not a big deal, especially since VirtualFile is refreshed inside the FilePathImpl.
This commit is contained in:
@@ -16,9 +16,7 @@
|
||||
package com.intellij.peer.impl;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.FilePathImpl;
|
||||
import com.intellij.openapi.vcs.actions.VcsContext;
|
||||
@@ -46,41 +44,24 @@ public class VcsContextFactoryImpl implements VcsContextFactory {
|
||||
}
|
||||
|
||||
public FilePath createFilePathOn(@NotNull final VirtualFile virtualFile) {
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<FilePath>() {
|
||||
public FilePath compute() {
|
||||
return new FilePathImpl(virtualFile);
|
||||
}
|
||||
});
|
||||
return new FilePathImpl(virtualFile);
|
||||
}
|
||||
|
||||
public FilePath createFilePathOn(final File file) {
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<FilePath>() {
|
||||
public FilePath compute() {
|
||||
return FilePathImpl.create(file);
|
||||
}
|
||||
});
|
||||
return FilePathImpl.create(file);
|
||||
}
|
||||
|
||||
public FilePath createFilePathOn(final File file, final NotNullFunction<File, Boolean> detector) {
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<FilePath>() {
|
||||
public FilePath compute() {
|
||||
VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByIoFile(file);
|
||||
if (virtualFile != null) {
|
||||
// detector information (loaded here lazily) is not needed - we have real file
|
||||
return FilePathImpl.create(file);
|
||||
}
|
||||
|
||||
return FilePathImpl.create(file, detector.fun(file).booleanValue());
|
||||
}
|
||||
});
|
||||
VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByIoFile(file);
|
||||
if (virtualFile != null) {
|
||||
// detector information (loaded here lazily) is not needed - we have real file
|
||||
return FilePathImpl.create(file);
|
||||
}
|
||||
return FilePathImpl.create(file, detector.fun(file).booleanValue());
|
||||
}
|
||||
|
||||
public FilePath createFilePathOn(final File file, final boolean isDirectory) {
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<FilePath>() {
|
||||
public FilePath compute() {
|
||||
return FilePathImpl.create(file, isDirectory);
|
||||
}
|
||||
});
|
||||
return FilePathImpl.create(file, isDirectory);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -89,19 +70,11 @@ public class VcsContextFactoryImpl implements VcsContextFactory {
|
||||
}
|
||||
|
||||
public FilePath createFilePathOnDeleted(final File file, final boolean isDirectory) {
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<FilePath>() {
|
||||
public FilePath compute() {
|
||||
return FilePathImpl.createForDeletedFile(file, isDirectory);
|
||||
}
|
||||
});
|
||||
return FilePathImpl.createForDeletedFile(file, isDirectory);
|
||||
}
|
||||
|
||||
public FilePath createFilePathOn(final VirtualFile parent, final String name) {
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<FilePath>() {
|
||||
public FilePath compute() {
|
||||
return new FilePathImpl(parent, name, false);
|
||||
}
|
||||
});
|
||||
return new FilePathImpl(parent, name, false);
|
||||
}
|
||||
|
||||
public LocalChangeList createLocalChangeList(Project project, @NotNull final String name) {
|
||||
|
||||
Reference in New Issue
Block a user