diff --git a/NvimView/NvimView/Typesetter.swift b/NvimView/NvimView/Typesetter.swift index 72b068d0..85167761 100644 --- a/NvimView/NvimView/Typesetter.swift +++ b/NvimView/NvimView/Typesetter.swift @@ -143,9 +143,12 @@ final class Typesetter { attributes: [.font: font, .ligature: NSNumber(integerLiteral: 1)] ) + if let cachedCtRuns = 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) return ctRuns } @@ -272,3 +275,5 @@ final class Typesetter { } } } + +private let ctRunsCache = SimpleCache(countLimit: 10000) diff --git a/VimR/VimR.xcodeproj/xcshareddata/xcschemes/VimR.xcscheme b/VimR/VimR.xcodeproj/xcshareddata/xcschemes/VimR.xcscheme index 911037e2..f6766544 100644 --- a/VimR/VimR.xcodeproj/xcshareddata/xcschemes/VimR.xcscheme +++ b/VimR/VimR.xcodeproj/xcshareddata/xcschemes/VimR.xcscheme @@ -27,6 +27,15 @@ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES"> + + + + @@ -39,17 +48,6 @@ - - - - - - - -