refactor(builtin): <+>-simplify Iter and Map Show and small write sequences - #4197
Merged
Conversation
…equences
- `Show for Iter` and `Show for Map` write their delimiters and separators
through `<+` templates with `\{cb => ...}` writer holes
- base64 `==` tail and a FixedArray iterator-test builder collapse into
single `<+` writes
Co-Authored-By: SeekMoon <seekmoon@moonbitlang.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The changes are localized refactors that preserve output semantics, and the updated patterns align with existing <+ usage in builtin without introducing new logic paths.
Pull request overview
This PR continues the ongoing <+ template-writing refactor in builtin by replacing small write_string / write_char sequences with <+ writes, including inline-writer holes (\{cb => ...}) where needed to keep write_object dispatch monomorphic.
Changes:
- Refactors
ShowforIterandMapto emit delimiters/separators via<+templates (using writer holes forwrite_object). - Simplifies base64 padding output by writing
"=="in a single<+call. - Simplifies a
FixedArrayiterator test’s expected-string builder to a single<+write per element.
File summaries
| File | Description |
|---|---|
| builtin/linked_hash_map.mbt | Uses <+ templates (with writer holes) for Map[K,V] Show::output punctuation and key/value emission. |
| builtin/iterator.mbt | Uses <+ templates for Iter[X] Show::output punctuation and separator+element emission. |
| builtin/fixedarray.mbt | Collapses StringBuilder writes in the iter test to a single <+ "\{x}\n" call. |
| builtin/console.mbt | Writes base64 "==" padding via a single <+ call. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Collaborator
Coverage Report for CI Build 6525Coverage increased (+0.007%) to 89.2%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the
<+template-writing simplification, split out of the closed#4195 for reviewability.
Show for IterandShow for Mapwrite their delimiters/separatorsthrough
<+templates with\{cb => ...}writer holes, keepingwrite_objectdispatch monomorphic==tail and a FixedArray iterator-test builder collapse intosingle
<+writesVerified:
moon check0 warnings/0 errors, builtin suite 2988/2988.Generated with SeekMoon