Skip to content

Commit 93d4723

Browse files
committed
Uses lazy loading to initialize the system character info reader.
1 parent 65eb9d1 commit 93d4723

2 files changed

Lines changed: 2 additions & 6 deletions

File tree

Source/InputMethodController+CandidateControllerDelegate.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,7 @@ extension McBopomofoInputMethodController: CandidateControllerDelegate {
205205
}
206206

207207
func checkIfSystemCharacterInfoReady() -> Bool {
208-
if charInfo == nil {
209-
charInfo = try? SystemCharacterInfo()
210-
}
211-
let ready = charInfo != nil
212-
return ready
208+
charInfo != nil
213209
}
214210

215211
func getSystemExplanation(for chr: String) -> String? {

Source/InputMethodController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class McBopomofoInputMethodController: IMKInputController {
5454
var currentClient: Any?
5555
var keyHandler: KeyHandler = KeyHandler()
5656
var state: InputState = InputState.Empty()
57-
var charInfo: SystemCharacterInfo?
57+
lazy var charInfo: SystemCharacterInfo? = try? SystemCharacterInfo()
5858

5959
// MARK: - IMKInputController methods
6060

0 commit comments

Comments
 (0)