mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
sync instead of concurrent set
This commit is contained in:
+16
-7
@@ -58,7 +58,7 @@ public class RefClassImpl extends RefJavaElementImpl implements RefClass {
|
||||
private static final int IS_LOCAL_MASK = 0x1000000;
|
||||
|
||||
private Set<RefClass> myBases; // singleton (to conserve the memory) or THashSet
|
||||
private volatile Set<RefClass> mySubClasses;
|
||||
private Set<RefClass> mySubClasses; // singleton (to conserve the memory) or THashSet
|
||||
private List<RefMethod> myConstructors;
|
||||
private RefMethodImpl myDefaultConstructor;
|
||||
private List<RefMethod> myOverridingMethods;
|
||||
@@ -334,21 +334,30 @@ public class RefClassImpl extends RefJavaElementImpl implements RefClass {
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Set<RefClass> getSubClasses() {
|
||||
public synchronized Set<RefClass> getSubClasses() {
|
||||
if (mySubClasses == null) return EMPTY_CLASS_SET;
|
||||
return mySubClasses;
|
||||
}
|
||||
|
||||
private void addSubClass(@NotNull RefClass refClass){
|
||||
private synchronized void addSubClass(@NotNull RefClass refClass){
|
||||
if (mySubClasses == null) {
|
||||
mySubClasses = ContainerUtil.newConcurrentSet();
|
||||
mySubClasses = Collections.singleton(refClass);
|
||||
return;
|
||||
}
|
||||
if (mySubClasses.size() == 1) {
|
||||
// convert from singleton
|
||||
mySubClasses = new THashSet<>(mySubClasses);
|
||||
}
|
||||
mySubClasses.add(refClass);
|
||||
}
|
||||
|
||||
private void removeSubClass(RefClass refClass){
|
||||
private synchronized void removeSubClass(RefClass refClass){
|
||||
if (mySubClasses == null) return;
|
||||
mySubClasses.remove(refClass);
|
||||
if (mySubClasses.size() == 1) {
|
||||
mySubClasses = null;
|
||||
}
|
||||
else {
|
||||
mySubClasses.remove(refClass);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user