mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
use less memory for file attributes
This commit is contained in:
+10
-10
@@ -831,13 +831,13 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
}
|
||||
|
||||
private SourceFileInfo(@NotNull DataInput in) throws IOException {
|
||||
final int projCount = in.readInt();
|
||||
final int projCount = DataInputOutputUtil.readINT(in);
|
||||
for (int idx = 0; idx < projCount; idx++) {
|
||||
final int projectId = in.readInt();
|
||||
final long stamp = in.readLong();
|
||||
final int projectId = DataInputOutputUtil.readINT(in);
|
||||
final long stamp = DataInputOutputUtil.readTIME(in);
|
||||
updateTimestamp(projectId, stamp);
|
||||
|
||||
final int pathsCount = in.readInt();
|
||||
final int pathsCount = DataInputOutputUtil.readINT(in);
|
||||
for (int i = 0; i < pathsCount; i++) {
|
||||
final int path = in.readInt();
|
||||
addOutputPath(projectId, path);
|
||||
@@ -847,18 +847,18 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
|
||||
public void save(@NotNull final DataOutput out) throws IOException {
|
||||
final int[] projects = getProjectIds().toArray();
|
||||
out.writeInt(projects.length);
|
||||
DataInputOutputUtil.writeINT(out, projects.length);
|
||||
for (int projectId : projects) {
|
||||
out.writeInt(projectId);
|
||||
out.writeLong(getTimestamp(projectId));
|
||||
DataInputOutputUtil.writeINT(out, projectId);
|
||||
DataInputOutputUtil.writeTIME(out, getTimestamp(projectId));
|
||||
final Object value = myProjectToOutputPathMap != null? myProjectToOutputPathMap.get(projectId) : null;
|
||||
if (value instanceof Integer) {
|
||||
out.writeInt(1);
|
||||
DataInputOutputUtil.writeINT(out, 1);
|
||||
out.writeInt(((Integer)value).intValue());
|
||||
}
|
||||
else if (value instanceof TIntHashSet) {
|
||||
final TIntHashSet set = (TIntHashSet)value;
|
||||
out.writeInt(set.size());
|
||||
DataInputOutputUtil.writeINT(out, set.size());
|
||||
final IOException[] ex = new IOException[] {null};
|
||||
set.forEach(new TIntProcedure() {
|
||||
public boolean execute(final int value) {
|
||||
@@ -877,7 +877,7 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
}
|
||||
}
|
||||
else {
|
||||
out.writeInt(0);
|
||||
DataInputOutputUtil.writeINT(out, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.newvfs.FileAttribute;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.util.indexing.FileBasedIndex;
|
||||
import com.intellij.util.io.DataInputOutputUtil;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -77,14 +78,14 @@ public class JavaLanguageLevelPusher implements FilePropertyPusher<LanguageLevel
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final FileAttribute PERSISTENCE = new FileAttribute("language_level_persistence", 1, true);
|
||||
private static final FileAttribute PERSISTENCE = new FileAttribute("language_level_persistence", 2, true);
|
||||
|
||||
@Override
|
||||
public void persistAttribute(VirtualFile fileOrDir, @NotNull LanguageLevel level) throws IOException {
|
||||
final DataInputStream iStream = PERSISTENCE.readAttribute(fileOrDir);
|
||||
if (iStream != null) {
|
||||
try {
|
||||
final int oldLevelOrdinal = iStream.readInt();
|
||||
final int oldLevelOrdinal = DataInputOutputUtil.readINT(iStream);
|
||||
if (oldLevelOrdinal == level.ordinal()) return;
|
||||
}
|
||||
finally {
|
||||
@@ -93,7 +94,7 @@ public class JavaLanguageLevelPusher implements FilePropertyPusher<LanguageLevel
|
||||
}
|
||||
|
||||
final DataOutputStream oStream = PERSISTENCE.writeAttribute(fileOrDir);
|
||||
oStream.writeInt(level.ordinal());
|
||||
DataInputOutputUtil.writeINT(oStream, level.ordinal());
|
||||
oStream.close();
|
||||
|
||||
for (VirtualFile child : fileOrDir.getChildren()) {
|
||||
|
||||
@@ -21,6 +21,7 @@ package com.intellij.openapi.vfs.newvfs;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.io.DataInputOutputUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -58,7 +59,7 @@ public class FileAttribute {
|
||||
DataInputStream stream = ManagingFS.getInstance().readAttribute(file, this);
|
||||
if (stream != null) {
|
||||
try {
|
||||
int actualVersion = stream.readInt();
|
||||
int actualVersion = DataInputOutputUtil.readINT(stream);
|
||||
if (actualVersion != myVersion) {
|
||||
stream.close();
|
||||
return null;
|
||||
@@ -74,7 +75,7 @@ public class FileAttribute {
|
||||
public DataOutputStream writeAttribute(VirtualFile file) {
|
||||
final DataOutputStream stream = ManagingFS.getInstance().writeAttribute(file, this);
|
||||
try {
|
||||
stream.writeInt(myVersion);
|
||||
DataInputOutputUtil.writeINT(stream, myVersion);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
Reference in New Issue
Block a user