mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cache scope attribute keys to reduce daemon garbage
This commit is contained in:
+11
-1
@@ -16,11 +16,21 @@
|
||||
package com.intellij.application.options.colors;
|
||||
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.util.containers.ConcurrentFactoryMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ScopeAttributesUtil {
|
||||
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
|
||||
private static final ConcurrentFactoryMap<String, TextAttributesKey> ourCache = new ConcurrentFactoryMap<String, TextAttributesKey>() {
|
||||
@Nullable
|
||||
@Override
|
||||
protected TextAttributesKey create(String scope) {
|
||||
return TextAttributesKey.find("SCOPE_KEY_" + scope);
|
||||
}
|
||||
};
|
||||
@NotNull
|
||||
public static TextAttributesKey getScopeTextAttributeKey(@NotNull String scope) {
|
||||
return TextAttributesKey.find("SCOPE_KEY_" + scope);
|
||||
return ourCache.get(scope);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user