mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
halve memory in interner
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package com.intellij.util.containers;
|
||||
|
||||
import com.intellij.openapi.util.LowMemoryWatcher;
|
||||
import com.intellij.util.containers.SLRUCache;
|
||||
import jsr166e.SequenceLock;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -24,6 +23,7 @@ public class RecentStringInterner {
|
||||
|
||||
public RecentStringInterner(int capacity) {
|
||||
final int stripes = 16;
|
||||
//noinspection unchecked
|
||||
myInterns = new SLRUCache[stripes];
|
||||
myStripeLocks = new Lock[myInterns.length];
|
||||
for(int i = 0; i < myInterns.length; ++i) {
|
||||
@@ -33,6 +33,26 @@ public class RecentStringInterner {
|
||||
public String createValue(String key) {
|
||||
return key;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String get(String key) {
|
||||
String value = myProtectedQueue.get(key);
|
||||
if (value == null) {
|
||||
value = myProbationalQueue.remove(key);
|
||||
if (value != null) {
|
||||
myProtectedQueue.put(value, value);
|
||||
}
|
||||
}
|
||||
if (value != null) {
|
||||
return value;
|
||||
}
|
||||
|
||||
value = key;
|
||||
put(key, value);
|
||||
|
||||
return value;
|
||||
}
|
||||
};
|
||||
myStripeLocks[i] = new SequenceLock();
|
||||
}
|
||||
@@ -43,7 +63,7 @@ public class RecentStringInterner {
|
||||
@Override
|
||||
public void run() {
|
||||
clear();
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user