Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ testing = ["xkb"]

[dependencies]
xkb-core = { version = "0.2.0", path = "xkb-core", optional = true }
compact_str = "0.8"

[dev-dependencies]
wkb = { package = "wayland-keyboard", path = ".", features = ["testing"] }
Expand Down
4 changes: 2 additions & 2 deletions bench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ echo ""

# ── 1. Speed Benchmarks (Criterion) ─────────────────────────────────
echo "▶ [1/3] Speed benchmarks (Criterion)"
echo " Running: cargo bench --bench bench_speed"
echo " Running: cargo bench --bench bench_setup --bench bench_key --bench bench_compose"
echo ""
cargo bench --bench bench_speed 2>&1 | tee "$RESULTS_DIR/speed.txt"
cargo bench --bench bench_setup --bench bench_key --bench bench_compose 2>&1 | tee "$RESULTS_DIR/speed.txt"
echo ""

# ── 2. Memory Benchmarks ────────────────────────────────────────────
Expand Down
15 changes: 8 additions & 7 deletions scripts/generate_benchmark_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,15 @@ function generateSpeedTable() {
const groups = fs.readdirSync(CRITERION_DIR)
.filter(d => !d.startsWith('.') && d !== 'report');

// Criterion stores groups with '_' separators in directory names
// Criterion stores group names using '/' as directory separators.
// The benchmark groups are defined in bench_setup.rs, bench_key.rs, bench_compose.rs.
const interesting = [
{ dir: 'full_setup', label: 'Full setup' },
{ dir: 'key_update', label: 'Key update' },
{ dir: 'key_get_utf8', label: 'Get UTF-8' },
{ dir: 'key_get_sym', label: 'Get keysym' },
{ dir: 'compose_setup', label: 'Compose setup', combine: ['compose_table_creation', 'compose_state_creation'] },
{ dir: 'compose_feed', label: 'Compose feed' },
{ dir: 'setup/with_compose', label: 'Full setup (with compose)' },
{ dir: 'setup/no_compose', label: 'Setup (no compose)' },
{ dir: 'key/update', label: 'Key update' },
{ dir: 'key/get_char', label: 'Key get char' },
{ dir: 'key/get_sym', label: 'Key get sym' },
{ dir: 'compose/feed', label: 'Compose feed' },
];

const rows = [];
Expand Down
10 changes: 6 additions & 4 deletions src/composer.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use compact_str::CompactString;

/// Token fed into the composer: either a regular character or a Compose key press
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Token {
Expand All @@ -8,7 +10,7 @@ pub enum Token {
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ComposeState {
Idle(char),
Composing(String),
Composing(CompactString),
Finished(char),
Cancelled,
}
Expand Down Expand Up @@ -84,12 +86,12 @@ impl Composer {
/// Returns an opinionated display string of the in-progress compose sequence.
/// Compose key shows as `·` if it is the last token pressed.
/// Characters show as themselves.
pub fn pending_string(&self) -> String {
pub fn pending_string(&self) -> CompactString {
if self.pending.is_empty() {
return String::new();
return CompactString::default();
}

let mut s = String::with_capacity(self.pending.len());
let mut s = CompactString::with_capacity(self.pending.len());
let last = self.pending.len() - 1;

for token in &self.pending[..last] {
Expand Down