cache scope attribute keys to reduce daemon garbage

This commit is contained in:
peter
2014-03-06 17:04:22 +01:00
parent ddd7530d07
commit b08a89da13
@@ -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);
}
}