Repository navigation
The accumulator lint names no builder, and warns when a variable holds a copy of the accumulator on every pass (D219, #919) - #3455
Merged
Merged
Conversation
added 2 commits
November 18, 2026 19:58
…s a copy of the accumulator on every pass (D219, #919)
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.
Closes #919. Ruled by Eric (D219): D34-C stands, D111's sentence describes the implementation,
StringBuilderleaves the prelude, and the lint covers what is still slow.s = piece ++ s) the warning no longer namesStringBuilder: append instead, building in the other direction, or collect the pieces and join them once.s = s ++ pieceappends in place whilesis the only holder of its text. When a variable is assignedsin the same loop (prev = s), it shares the text at the next append, which copies all of it. Measured: 20,000 passes 15 ms, 40,000 passes 54 ms; the plain append does 200,000 in 3 ms. Both orders warn.letcopy in the loop body is not flagged (it can die before the next append), nor a copy made outside an inner loop (one copy).StringBuilderwas already import-gated (use std.string.StringBuilder), and the normative spec has no builder sentence, so no spec text changes.Two tests: the warnings, and what stays quiet. Battery green on the branch tip.