1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-24 11:37:32 +03:00

Cache CTRuns

This commit is contained in:
Tae Won Ha 2020-02-10 20:58:00 +01:00
parent d191476bfa
commit 0b00529434
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
2 changed files with 14 additions and 13 deletions

View File

@ -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<NSAttributedString, [CTRun]>(countLimit: 10000)

View File

@ -27,6 +27,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "4BEBA5041CFF374B00673FDF"
BuildableName = "VimR.app"
BlueprintName = "VimR"
ReferencedContainer = "container:VimR.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
@ -39,17 +48,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "4BEBA5041CFF374B00673FDF"
BuildableName = "VimR.app"
BlueprintName = "VimR"
ReferencedContainer = "container:VimR.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
@ -71,8 +69,6 @@
ReferencedContainer = "container:VimR.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"