mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
add FSRecords.getNameSequence to avoid unnecessary allocations
This commit is contained in:
+5
-1
@@ -1103,11 +1103,15 @@ public class FSRecords implements Forceable {
|
||||
}
|
||||
|
||||
public static String getName(int id) {
|
||||
return getNameSequence(id).toString();
|
||||
}
|
||||
|
||||
public static CharSequence getNameSequence(int id) {
|
||||
try {
|
||||
r.lock();
|
||||
try {
|
||||
final int nameId = getRecordInt(id, NAME_OFFSET);
|
||||
return nameId != 0 ? FileNameCache.getVFileName(nameId).toString() : "";
|
||||
return nameId != 0 ? FileNameCache.getVFileName(nameId) : "";
|
||||
}
|
||||
finally {
|
||||
r.unlock();
|
||||
|
||||
+5
-4
@@ -22,6 +22,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.FileTypeRegistry;
|
||||
import com.intellij.openapi.fileTypes.FileTypes;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.LowMemoryWatcher;
|
||||
import com.intellij.openapi.util.ShutDownTracker;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
@@ -277,7 +278,7 @@ public class PersistentFSImpl extends PersistentFS implements ApplicationCompone
|
||||
@NotNull FileAttributes attributes) {
|
||||
String name = file.getName();
|
||||
if (!name.isEmpty()) {
|
||||
if (namesEqual(fs, name, FSRecords.getName(id))) return false; // TODO: Handle root attributes change.
|
||||
if (namesEqual(fs, name, FSRecords.getNameSequence(id))) return false; // TODO: Handle root attributes change.
|
||||
}
|
||||
else {
|
||||
if (areChildrenLoaded(id)) return false; // TODO: hack
|
||||
@@ -305,8 +306,8 @@ public class PersistentFSImpl extends PersistentFS implements ApplicationCompone
|
||||
return FSRecords.getParent(id);
|
||||
}
|
||||
|
||||
private static boolean namesEqual(@NotNull VirtualFileSystem fs, @NotNull String n1, String n2) {
|
||||
return fs.isCaseSensitive() ? n1.equals(n2) : n1.equalsIgnoreCase(n2);
|
||||
private static boolean namesEqual(@NotNull VirtualFileSystem fs, @NotNull CharSequence n1, CharSequence n2) {
|
||||
return Comparing.equal(n1, n2, fs.isCaseSensitive());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -380,7 +381,7 @@ public class PersistentFSImpl extends PersistentFS implements ApplicationCompone
|
||||
}
|
||||
|
||||
for (final int childId : children) {
|
||||
if (namesEqual(fs, childName, FSRecords.getName(childId))) return childId;
|
||||
if (namesEqual(fs, childName, FSRecords.getNameSequence(childId))) return childId;
|
||||
}
|
||||
|
||||
final VirtualFile fake = new FakeVirtualFile(parent, childName);
|
||||
|
||||
Reference in New Issue
Block a user