mirror of
https://github.com/qvacua/vimr.git
synced 2024-11-24 03:25:03 +03:00
Refactor slightly
This commit is contained in:
parent
911aea2ae3
commit
4bb04b4ed1
@ -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<NSAttributedString, [CTRun]>(countLimit: 5000)
|
||||
private let log = OSLog(subsystem: Defs.loggerSubsystem, category: Defs.LoggerCategory.view)
|
||||
|
||||
private func ctRuns(from utf16Chars: Array<Unicode.UTF16.CodeUnit>, 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<NSAttributedString, [CTRun]>(countLimit: 20000)
|
||||
|
Loading…
Reference in New Issue
Block a user