Cut input method startup from ~0.95 s to ~0.15 s
After login macOS starts the input method on first use, and keys typed while it loads its data were delayed or lost. Startup now: - parses lexicon.txt as raw bytes (no per-line String splitting or Double parsing) and builds the tone-ignoring index lazily on a background queue; - loads the precomputed English dictionary and bigram table (shared with the Windows build) instead of retraining the bigram model on every launch, and uses binary search instead of building a 230k-entry Set. Measured (release, warm cache): lexicon 0.65 -> 0.10 s, English 0.30 -> 0.04 s. The Windows (Python) core also builds its toneless index lazily: 0.56 -> 0.37 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,9 @@ mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
|
||||
cp "$BIN" "$APP/Contents/MacOS/AutoZhuyin"
|
||||
cp Resources/Info.plist "$APP/Contents/Info.plist"
|
||||
cp Resources/lexicon.txt Resources/english-common.txt Resources/classifier-weights.json "$APP/Contents/Resources/"
|
||||
# Precomputed English dictionary and bigram table (shared with the Windows build).
|
||||
python3 -I windows/tools/build_data.py >/dev/null
|
||||
cp windows/autozhuyin/data/english-dict.txt windows/autozhuyin/data/english-bigram.json "$APP/Contents/Resources/"
|
||||
|
||||
if [ ! -f build/icon.tiff ]; then
|
||||
xcrun swift scripts/make-icon.swift build/icon.tiff
|
||||
|
||||
Reference in New Issue
Block a user