diff --git a/NvimView/NvimView/Typesetter.swift b/NvimView/NvimView/Typesetter.swift index 3b5da586..c04a0d7e 100644 --- a/NvimView/NvimView/Typesetter.swift +++ b/NvimView/NvimView/Typesetter.swift @@ -134,8 +134,9 @@ final class Typesetter { return runs.flatMap { $0 } } - private let log = OSLog(subsystem: Defs.loggerSubsystem, - category: Defs.LoggerCategory.view) + + private let ctRunsCache = SimpleCache(countLimit: 5000) + private let log = OSLog(subsystem: Defs.loggerSubsystem, category: Defs.LoggerCategory.view) private func ctRuns(from utf16Chars: Array, font: NSFont) -> [CTRun] { let attrStr = NSAttributedString( @@ -143,12 +144,12 @@ final class Typesetter { attributes: [.font: font, .ligature: NSNumber(integerLiteral: 1)] ) - if let cachedCtRuns = ctRunsCache.object(forKey: attrStr) { return cachedCtRuns } + if let cachedCtRuns = self.ctRunsCache.object(forKey: attrStr) { return cachedCtRuns } let ctLine = CTLineCreateWithAttributedString(attrStr) guard let ctRuns = CTLineGetGlyphRuns(ctLine) as? [CTRun] else { return [] } - ctRunsCache.set(object: ctRuns, forKey: attrStr) + self.ctRunsCache.set(object: ctRuns, forKey: attrStr) return ctRuns } @@ -275,5 +276,3 @@ final class Typesetter { } } } - -private let ctRunsCache = SimpleCache(countLimit: 20000)