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

moonbitlang / core / 4772
91%

Build:
DEFAULT BRANCH: main
Ran 26 Jun 2026 11:34PM UTC
Jobs 1
Files 379
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

26 Jun 2026 11:33PM UTC coverage: 90.973% (+0.009%) from 90.964%
4772

push

github

bobzhang
perf(builtin): use unchecked array access in sort inner loops

The array sort helpers operate on `MutArrayView` and index it with the
checked `arr[i]` accessor (`MutArrayView::at` / `op_set`), which performs
a bounds check and goes through non-inlined `buf()` / `start()` / `len()`
accessors on every comparison and swap. Profiling `Array::sort` showed
~53% of the time in `MutArrayView::at` / `set` alone, with zero allocation.

Every index in these helpers is derived from the view's own length and is
provably in bounds, so switch the hot reads/writes to `unsafe_get` /
`unsafe_set`. This covers both `sort` (Compare) and `sort_by`, including
`swap`, partition, bubble, insertion, merge, heap sift-down, choose-pivot
and reverse-in-place.

Bench (native, distinct Int keys):
  sort    n=1000:    52.8 µs -> 8.6 µs   (6.1x)
  sort    n=100000:  8.65 ms -> 3.88 ms  (2.2x)
  sort_by n=10000:   801 µs  -> 280 µs   (2.9x)

Gains are data-dependent; duplicate-heavy inputs see closer to 2x.
Adds builtin/sort_bench_test.mbt.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

41 of 41 new or added lines in 2 files covered. (100.0%)

15167 of 16672 relevant lines covered (90.97%)

189010.29 hits per line

Jobs
ID Job ID Ran Files Coverage
1 4772.1 26 Jun 2026 11:34PM UTC 380
90.99
GitHub Action Run
Source Files on build 4772
  • Tree
  • List 379
  • Changed 2
  • Source Changed 2
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • 0d1b1128 on github
  • Prev Build on main (#4761)
  • Next Build on main (#4776)
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