mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Cache the path of VFileEvent to avoid recomputing it for every listener
This commit is contained in:
+1
-1
@@ -61,7 +61,7 @@ public class VFileContentChangeEvent extends VFileEvent {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPath() {
|
||||
protected String computePath() {
|
||||
return myFile.getPath();
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public class VFileCopyEvent extends VFileEvent {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPath() {
|
||||
protected String computePath() {
|
||||
return myNewParent.getPath() + "/" + myNewChildName;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ public class VFileCreateEvent extends VFileEvent {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPath() {
|
||||
protected String computePath() {
|
||||
return myParent.getPath() + "/" + myChildName;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public class VFileDeleteEvent extends VFileEvent {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPath() {
|
||||
protected String computePath() {
|
||||
return myFile.getPath();
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.vfs.newvfs.events;
|
||||
|
||||
import com.intellij.openapi.util.AtomicNotNullLazyValue;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileSystem;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -26,6 +27,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
public abstract class VFileEvent {
|
||||
private final boolean myIsFromRefresh;
|
||||
private final Object myRequestor;
|
||||
@NotNull private final AtomicNotNullLazyValue<String> myPath = AtomicNotNullLazyValue.createValue(this::computePath);
|
||||
|
||||
public VFileEvent(Object requestor, final boolean isFromRefresh) {
|
||||
myRequestor = requestor;
|
||||
@@ -41,7 +43,12 @@ public abstract class VFileEvent {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public abstract String getPath();
|
||||
public String getPath() {
|
||||
return myPath.getValue();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected abstract String computePath();
|
||||
|
||||
/**
|
||||
* Returns the VirtualFile which this event belongs to.
|
||||
|
||||
@@ -59,7 +59,7 @@ public class VFileMoveEvent extends VFileEvent {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPath() {
|
||||
protected String computePath() {
|
||||
return myFile.getPath();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -101,7 +101,7 @@ public class VFilePropertyChangeEvent extends VFileEvent {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPath() {
|
||||
protected String computePath() {
|
||||
return myFile.getPath();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user