feat: add small performance improvements

This commit is contained in:
Miwa / Ensan
2025-06-29 21:48:02 +09:00
parent fe2c1ec4ae
commit e329bbddd5
2 changed files with 2 additions and 11 deletions

View File

@ -706,15 +706,6 @@ public final class DicdataStore {
return self.mmValue[former * self.midCount + latter]
}
private static let possibleLOUDS: Set<Character> = [
" ", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "*", "", "", "", "´", "¨", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "", "", "(", ")", "#", "%", "&", "^", "_", "'", "\""
]
//
static func existLOUDS(for character: Character) -> Bool {
Self.possibleLOUDS.contains(character)
}
/*

View File

@ -140,11 +140,11 @@ struct TypoCorrectionGenerator: Sendable {
guard let first = components.first?.string.first?.toKatakana() else {
return false
}
return !CharacterUtils.isRomanLetter(first) && !DicdataStore.existLOUDS(for: first)
return !CharacterUtils.isRomanLetter(first)
}
fileprivate static func getTypo(_ elements: some Collection<ComposingText.InputElement>, frozen: Bool = false) -> [TypoCandidate] {
let key = elements.reduce(into: "") {$0.append($1.character)}.toKatakana()
let key = elements.reduce(into: "") {$0.append($1.character.toKatakana())}
if (elements.allSatisfy {$0.inputStyle == .direct}) {
let dictionary: [String: [TypoUnit]] = frozen ? [:] : Self.directPossibleTypo