Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: reuse collection types for DocFitter #1491

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

TimothyMakkison
Copy link
Contributor

@TimothyMakkison TimothyMakkison commented Feb 19, 2025

Instead of creating a new instance of StringBuilder and Stack<PrintCommand> every time DocFitter.Fit is called we instead create a single instance of each in DocPrinter and pass it into DocFitter.Fit.

This could be replaced by using ValueStringBuilder and ValueListBuilder, the latter would be beneficial as unlike Stack<T> we can access items by index instead of the O(n) lookup time with ElementAt.

Before

Method Mean Error StdDev Median Gen0 Gen1 Gen2 Allocated
Default_CodeFormatter 231.5 ms 4.62 ms 8.78 ms 228.0 ms 11000.0000 4000.0000 1000.0000 95.82 MB

After

Method Mean Error StdDev Gen0 Gen1 Gen2 Allocated
Default_CodeFormatter 227.0 ms 4.51 ms 6.33 ms 10000.0000 4000.0000 1000.0000 90.03 MB

@TimothyMakkison TimothyMakkison force-pushed the reuse_docfit_collections branch from 6c89713 to f48bdc8 Compare February 19, 2025 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant