Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Printer: make propagateForcedBreaks allocation-free. #325

Merged
merged 1 commit into from
Mar 16, 2021

Conversation

cristianoc
Copy link
Contributor

Instead of returning a copy of the doc with some IfBreaks resolved, make doc mutable to mark when an IfBreak has been resolved to the first branch.

This makes the function allocation-free, but with side effects on the doc.

Instead of returning a copy of the doc with some `IfBreak`s resolved, make doc mutable to mark when an `IfBreak` has been resolved to the first branch.

This makes the function allocation-free, but with side effects on the doc.
@chenglou
Copy link
Member

Before:
Screen Shot 2021-03-15 at 5 41 39 PM
After:
Screen Shot 2021-03-15 at 5 42 57 PM

Damn...
Though making that doc mutable is slightly unfortunate. But the difference is huge!

Copy link
Contributor

@IwanKaramazow IwanKaramazow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes actually more sense than the original immutable implementation.
The allocation gains are incredible again.

@IwanKaramazow IwanKaramazow merged commit 3cd561a into master Mar 16, 2021
@IwanKaramazow IwanKaramazow deleted the propagateForcedBreaks branch March 16, 2021 07:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants