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

moonbitlang / core / 1457
92%

Build:
DEFAULT BRANCH: main
Ran 05 Oct 2025 07:55AM UTC
Jobs 1
Files 255
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

05 Oct 2025 07:55AM UTC coverage: 89.194% (+0.007%) from 89.187%
1457

push

github

bobzhang
refactor(immut/sorted_map): Replace array-based iterator with continuation-based design

Apply the same continuation-based iterator pattern used in SortedSet to
SortedMap for consistency and improved design.

Key improvements:
- Memory efficiency: Continuation tree replaces mutable array stack
- Functional design: Iterator wraps a closure (() -> (K, V)?) for composability
- Cleaner implementation: Eliminates explicit stack management methods
- Same performance: Both are O(n) traversal with O(log n) space in average case

Implementation details:
- Iterator[K, V]: Wraps a stateful closure that yields the next (key, value) pair
- Tree[K, V]: Continuation structure encoding remaining traversal state
  - Leaf: No more elements to process
  - More(left, right, key, value): Process left, yield (key, value), then right
- into_iterator(): Creates closure with mutable state (next, cont) captured
- Uses for-loop with pattern matching for elegant in-order traversal

Changes to traits_impl.mbt:
- Updated Eq implementation to use into_iterator() with while-loop pattern
- Updated Compare implementation to use into_iterator() with while-loop pattern
- Both now use modern pattern matching style (guard...else, break)
- Maintains size-first comparison optimization

Testing:
- Enhanced test to verify all elements in sequence
- Added check for proper iterator exhaustion
- All 5634 tests pass successfully

File changes:
- Renamed: inorder_iterator.mbt -> external_iterator.mbt
- Updated: traits_impl.mbt to use new iterator API

No API changes - this is an internal implementation refactoring only.

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

2 existing lines in 1 file now uncovered.

9261 of 10383 relevant lines covered (89.19%)

193885.79 hits per line

Uncovered Existing Lines

Lines Coverage ∆ File
2
88.46
3.61% immut/sorted_map/traits_impl.mbt
Jobs
ID Job ID Ran Files Coverage
1 1457.1 05 Oct 2025 07:55AM UTC 256
89.22
GitHub Action Run
Source Files on build 1457
  • Tree
  • List 255
  • Changed 2
  • Source Changed 2
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • 914d0582 on github
  • Prev Build on main (#1455)
  • Next Build on main (#1459)
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

© 2025 Coveralls, Inc