Skip to content

Optimize TodoWidget filtering and alphabetical sorting allocations#805

Merged
multiplex55 merged 1 commit intomasterfrom
codex/optimize-todowidget-filtering-and-sorting
Feb 7, 2026
Merged

Optimize TodoWidget filtering and alphabetical sorting allocations#805
multiplex55 merged 1 commit intomasterfrom
codex/optimize-todowidget-filtering-and-sorting

Conversation

@multiplex55
Copy link
Copy Markdown
Owner

Motivation

  • Reduce repeated to_lowercase() allocations during todo filtering and alphabetical sorting to improve performance on large todo lists.
  • Favor cheap ASCII-fast checks when possible while retaining correct Unicode-capable fallback behavior.
  • Add a micro-benchmark to measure allocation/throughput improvements for large lists.

Description

  • Precompute normalized filter tags once per render pass via normalized_filter_tags() and thread that slice through entry_matches_filters and filter_entries instead of lowercasing per comparison.
  • Change tags_match to accept normalized filters and use eq_ignore_ascii_case before falling back to to_lowercase().contains(...) to get a fast-path for ASCII-equal matches.
  • Optimize alphabetical sorting in sort_entries with a decorate-sort-undecorate approach (precompute lowercase keys, sort, then rebuild entries) to avoid repeated to_lowercase() calls inside the comparator.
  • Update the filters_combine_before_sorting unit test to use the new normalized flow and add a Criterion benchmark benches/todo_widget_filtering.rs, plus register the bench in Cargo.toml.

Testing

  • Ran cargo fmt which completed successfully.
  • Ran cargo test --lib dashboard::widgets::todo which could not run due to the environment toolchain (rustc 1.87.0) being older than a dependency requirement (time requires rustc 1.88.0).
  • Ran cargo bench --bench todo_widget_filtering --no-run which was likewise blocked by the same toolchain incompatibility, but a micro-benchmark was added and is runnable once the toolchain is updated.

Codex Task

@multiplex55 multiplex55 merged commit b44f52b into master Feb 7, 2026
1 check passed
@multiplex55 multiplex55 deleted the codex/optimize-todowidget-filtering-and-sorting branch February 8, 2026 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant