<commit_before>package de.setsoftware.reviewtool.ui.views;

import java.util.HashMap;
import java.util.Map;

import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;

import de.setsoftware.reviewtool.base.Logger;

/**
 * Caches images and has nice factory methods for them.
 */
public class ImageCache {

    private static final Rectangle TREE_IMAGE_SIZE = new Rectangle(0, 0, 16, 16);

    private static Map<String, Image> images = new HashMap<>();

    /**
     * Returns a filled circle in tree icon size in the given color.
     */
    public static Image getColoredDot(RGB rgb) {
        final String key = "cd:" + rgb.toString();
        if (images.containsKey(key)) {
            return images.get(key);
        }

        final Device dev = Display.getDefault();
        final Rectangle rect = TREE_IMAGE_SIZE;
        final Image img = new Image(dev, rect);
        final GC gc = new GC(img);
        final Color color = new Color(dev, rgb);
        gc.setForeground(color);
        gc.setBackground(color);
        gc.fillOval(rect.width / 2, rect.height / 4, rect.width / 2, rect.height / 2);
        color.dispose();
        gc.dispose();

        cache(key, img);
        return img;
    }

    private static void cache(final String key, final Image img) {
        images.put(key, img);
        Logger.debug("image cache has " + images.size() + " items after caching " + key);
    }

    /**
     * Returns a rectangle in tree icon size with a border and fill in the given colors.
     */
    public static Image getColoredRectangle(RGB border, RGB fill) {
        final String key = "cr:" + border.toString() + fill.toString();
        if (images.containsKey(key)) {
            return images.get(key);
        }
<commit_msg>removed debug logging in image cache again. no sign of leak found in tests<commit_after>package de.setsoftware.reviewtool.ui.views;

import java.util.HashMap;
import java.util.Map;

import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;

/**
 * Caches images and has nice factory methods for them.
 */
public class ImageCache {

    private static final Rectangle TREE_IMAGE_SIZE = new Rectangle(0, 0, 16, 16);

    private static Map<String, Image> images = new HashMap<>();

    /**
     * Returns a filled circle in tree icon size in the given color.
     */
    public static Image getColoredDot(RGB rgb) {
        final String key = "cd:" + rgb.toString();
        if (images.containsKey(key)) {
            return images.get(key);
        }

        final Device dev = Display.getDefault();
        final Rectangle rect = TREE_IMAGE_SIZE;
        final Image img = new Image(dev, rect);
        final GC gc = new GC(img);
        final Color color = new Color(dev, rgb);
        gc.setForeground(color);
        gc.setBackground(color);
        gc.fillOval(rect.width / 2, rect.height / 4, rect.width / 2, rect.height / 2);
        color.dispose();
        gc.dispose();

        cache(key, img);
        return img;
    }

    private static void cache(final String key, final Image img) {
        images.put(key, img);
    }

    /**
     * Returns a rectangle in tree icon size with a border and fill in the given colors.
     */
    public static Image getColoredRectangle(RGB border, RGB fill) {
        final String key = "cr:" + border.toString() + fill.toString();
        if (images.containsKey(key)) {
            return images.get(key);
        }

{'fraction_non_alphanumeric': 0.11244143675169183, 'fraction_numerical': 0.0052056220718375845, 'mean_word_length': 2.6323251417769375, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2897040', 'n_tokens_mistral': 1168, 'n_tokens_neox': 1118, 'n_words': 343}