mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
FileUtil: comparing only names (-1 minute on Chromium)
This commit is contained in:
@@ -24,16 +24,16 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
public abstract class SpecificNameItemProcessor implements PsiFileSystemItemProcessor {
|
||||
private final String myName;
|
||||
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
protected SpecificNameItemProcessor(String name) {
|
||||
myName = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(String name, boolean isDirectory) {
|
||||
return FileUtil.pathsEqual(myName, name);
|
||||
return FileUtil.namesEqual(myName, name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -798,10 +798,19 @@ public class FileUtil extends FileUtilRt {
|
||||
|
||||
path1 = toCanonicalPath(path1);
|
||||
path2 = toCanonicalPath(path2);
|
||||
//noinspection ConstantConditions
|
||||
return PATH_HASHING_STRATEGY.equals(path1, path2);
|
||||
}
|
||||
|
||||
/**
|
||||
* optimized version of pathsEqual - it only compares pure names, without file separators
|
||||
*/
|
||||
public static boolean namesEqual(@Nullable String name1, @Nullable String name2) {
|
||||
if (name1 == name2) return true;
|
||||
if (name1 == null || name2 == null) return false;
|
||||
|
||||
return PATH_HASHING_STRATEGY.equals(name1, name2);
|
||||
}
|
||||
|
||||
public static int compareFiles(@Nullable File file1, @Nullable File file2) {
|
||||
return comparePaths(file1 == null ? null : file1.getPath(), file2 == null ? null : file2.getPath());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user