diff --git a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/themes/css/CSSTokenProvider.java b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/themes/css/CSSTokenProvider.java index a2d8076e5..1ad10102d 100644 --- a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/themes/css/CSSTokenProvider.java +++ b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/themes/css/CSSTokenProvider.java @@ -16,6 +16,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jface.text.TextAttribute; @@ -46,6 +47,7 @@ public List getStyles() { } private final Map tokenMaps = new HashMap<>(); + private final Map getTokenReturnValueCache = new ConcurrentHashMap<>(); private final CSSParser parser; @@ -86,11 +88,11 @@ public IToken getToken(@Nullable final String type) { if (type == null) return null; - final IStyle style = parser.getBestStyle(StringUtils.splitToArray(type, '.')); - if (style == null) - return null; - - return tokenMaps.get(style); + return getTokenReturnValueCache.computeIfAbsent(type, + t -> { + IStyle style = parser.getBestStyle(StringUtils.splitToArray(type, '.')); + return style == null ? null : tokenMaps.get(style); + }); } @Nullable