• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

moonbitlang / core / 3911

24 Apr 2026 01:53AM UTC coverage: 94.87% (-0.001%) from 94.871%
3911

push

github

bobzhang
perf(argparse): thread ArrayView[String] through subcommand dispatch

Four `.to_owned()` calls in the parser hot path were eagerly
materializing an `Array[String]` from what downstream consumers accept
as `ArrayView[String]`:

- `default_argv()` returns the initial argv slice — `Command::parse`
  already declares its `argv?` parameter as `ArrayView[String]`.
- `parser.mbt` built two `rest` arrays (the help-subcommand path and
  the generic-subcommand dispatch path) only to pass them to
  `parse_command`, which also takes `ArrayView[String]`.
- `parser_lookup.mbt::split_long` was calling `to_owned()` on
  `ArrayView[StringView]` just to invoke `.join("=")`, which works
  directly on the view.

Returning / passing views saves one `Array` allocation per call. On a
program with nested subcommands, the dispatch path takes several of
these per invocation. `resolve_help_target` only needs pattern-match
and iteration over `argv`, which work on `ArrayView[String]` — changed
the private-signature's parameter type accordingly.

No mbti change: `default_argv` and `resolve_help_target` are private
`fn`s, and `parse_command` already accepted `ArrayView[String]`.

1 of 2 new or added lines in 2 files covered. (50.0%)

14721 of 15517 relevant lines covered (94.87%)

221128.78 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

79.13
/argparse/parser.mbt


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc