refactor: move the TUI into the library so it compiles once
src/main.rs re-declared the entire module tree (`mod app; mod config;
...`), which made the binary a second independent crate. Every module --
and the whole rust-i18n translation table generated by `i18n!` -- was
compiled twice, and 281 unit tests were executed twice.
Move all application code to src/run.rs inside the library, exposed as
`keydr::run()`. main.rs is now a 10-line entry point.
Mechanical changes only; no logic was altered:
- src/run.rs is src/main.rs minus the crate-root preamble
- `fn main()` -> `pub fn run()`; `struct Cli` -> `pub struct Cli`
- bare `use app::...` / inline `ui::theme::Theme` references are now
qualified with `crate::` (19 imports, 342 inline references), since
they are no longer resolving from the crate root
Clean release build, measured with --timings:
before after
keydr (bin) 33.7s 0.3s
keydr (lib) 26.0s 31.0s
keydr total 61.0s 32.4s (-28.6s)
total unit-seconds 292.2s 264.5s
wall clock 2m14s 1m46s (-28s, -21%)
Test coverage is unchanged: 341 unique tests before and after (verified
by diffing `--list` output, not just counts). The apparent drop from
622 to 340 executions is the duplicate run disappearing -- 281 tests
previously ran once per crate copy.
Verified the binary still works: --help/--version intact, TUI renders
its welcome screen under tmux, and translations resolve (checked both
English and German).
Note: `cargo check --benches` fails with 3 errors, but those are
pre-existing on main (NgramStat field renames) and unrelated.
This commit is contained in:
+12
-6
@@ -1,12 +1,15 @@
|
|||||||
// Library target exists solely for criterion benchmarks.
|
// The keydr library. This holds ALL application code, including the TUI
|
||||||
// The binary entry point is main.rs; this file re-declares the module tree so
|
// event loop and rendering (`run`), so that everything is compiled exactly
|
||||||
// that bench harnesses can import types via `keydr::engine::*` / `keydr::session::*`.
|
// once. src/main.rs is a thin wrapper that just calls `run()`.
|
||||||
// Most code is only exercised through the binary, so suppress dead_code warnings.
|
//
|
||||||
|
// Previously main.rs re-declared this same module tree, making the binary a
|
||||||
|
// second independent crate: every module -- and the whole rust-i18n
|
||||||
|
// translation table generated by `i18n!` -- was compiled twice.
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
rust_i18n::i18n!("locales", fallback = "en");
|
rust_i18n::i18n!("locales", fallback = "en");
|
||||||
|
|
||||||
// Public: used by benchmarks and the generate_test_profiles binary
|
// Public: used by the binary, benchmarks, and generate_test_profiles.
|
||||||
pub mod config;
|
pub mod config;
|
||||||
pub mod engine;
|
pub mod engine;
|
||||||
pub mod keyboard;
|
pub mod keyboard;
|
||||||
@@ -14,9 +17,12 @@ pub mod l10n;
|
|||||||
pub mod session;
|
pub mod session;
|
||||||
pub mod store;
|
pub mod store;
|
||||||
|
|
||||||
// Private: required transitively by engine/session (won't compile without them)
|
// Internal to the application, but `run` needs them.
|
||||||
mod app;
|
mod app;
|
||||||
mod event;
|
mod event;
|
||||||
mod generator;
|
mod generator;
|
||||||
mod i18n;
|
mod i18n;
|
||||||
|
mod run;
|
||||||
mod ui;
|
mod ui;
|
||||||
|
|
||||||
|
pub use run::run;
|
||||||
|
|||||||
+8
-7530
File diff suppressed because it is too large
Load Diff
+7508
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user