<commit_before>import Foundation

#if os(iOS)
import UIKit
#elseif os(OSX)
import AppKit
#endif

struct RenderingInterval {
    let from: Int
    let to: Int
}

enum ColoringMode {
    case rgb, greyscale, alphaOnly
}

class NodeRenderer {

    let view: MView?

    fileprivate let onNodeChange: () -> Void
    fileprivate let disposables = GroupDisposable()
    fileprivate var active = false
    weak var animationCache: AnimationCache?

    init(node: Node, view: MView?, animationCache: AnimationCache?) {
        self.view = view
        self.animationCache = animationCache

        onNodeChange = {
            guard let isAnimating = animationCache?.isAnimating(node) else {
                return
            }

            if isAnimating {
                return
            }

            view?.setNeedsDisplay()
        }

        addObservers()
    }
<commit_msg>Fix memory leak in renderer<commit_after>import Foundation

#if os(iOS)
import UIKit
#elseif os(OSX)
import AppKit
#endif

struct RenderingInterval {
    let from: Int
    let to: Int
}

enum ColoringMode {
    case rgb, greyscale, alphaOnly
}

class NodeRenderer {

    weak var view: MView?

    fileprivate let onNodeChange: () -> Void
    fileprivate let disposables = GroupDisposable()
    fileprivate var active = false
    weak var animationCache: AnimationCache?

    init(node: Node, view: MView?, animationCache: AnimationCache?) {
        self.view = view
        self.animationCache = animationCache

        onNodeChange = {
            guard let isAnimating = animationCache?.isAnimating(node) else {
                return
            }

            if isAnimating {
                return
            }

            view?.setNeedsDisplay()
        }

        addObservers()
    }

{'fraction_non_alphanumeric': 0.07332205301748448, 'fraction_numerical': 0.0, 'mean_word_length': 2.1678571428571427, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4894451', 'n_tokens_mistral': 511, 'n_tokens_neox': 484, 'n_words': 141}