Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
import consulo.ui.color.ColorValue;
import consulo.ui.color.RGBColor;
import consulo.ui.util.ColorValueUtil;
import consulo.util.collection.HashingStrategy;
import consulo.util.collection.Maps;
import consulo.util.lang.lazy.LazyValue;
import consulo.xml.psi.xml.XmlAttribute;
import consulo.xml.psi.xml.XmlTokenType;
import jakarta.annotation.Nonnull;
Expand Down Expand Up @@ -194,20 +197,16 @@ public ColorValue getColorValue() {
return colorValue;
}

private static final Map<String, ColorValue> colorsMap = new HashMap<>();

public static ColorValue getColorValue(String name) {
return colorsMap.get(name.toLowerCase(Locale.ROOT));
}

private static void initColorsMap() {
private static final LazyValue<Map<String, ColorValue>> colorsMap = LazyValue.notNull(() -> {
Map<String, ColorValue> map = Maps.newHashMap(HashingStrategy.caseInsensitive());
for (NamedColor c : values()) {
colorsMap.put(c.getName(), c.getColorValue());
map.put(c.name(), c.getColorValue());
}
}
return map;
});

static {
initColorsMap();
public static ColorValue getColorValue(String name) {
return colorsMap.get().get(name);
}
}

Expand Down
Loading