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

Replace use of text/template with string manipulations #425

Merged

Conversation

pgimalac
Copy link
Contributor

Fixes #424.

This PR replaces using a template to generate the graph in dot format with directly writing strings in the writer.
In particular it avoids disabling dead code elimination.

I tried to keep the same whitespaces (tab, newlines) as in the template to avoid modifying the test cases, and increase confidence that the change is equivalent.
I'd be very happy to remove the extra tab and newlines as they just make the code less readable.

The proposed implementation uses fmt.Fprintf to simplify, but it can be optimized by just using w.Write directly instead, avoiding some parsing and allocations. I considered that it was not a hot path so making the code simpler was worth it.

@CLAassistant
Copy link

CLAassistant commented Feb 17, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@JacobOaks JacobOaks left a comment

Choose a reason for hiding this comment

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

LGTM. For the purposes of this change, keeping the tests the same seems like a good idea to keep confidence. We can clean up the spacing later. Thanks!

@JacobOaks JacobOaks merged commit 1190017 into uber-go:master Feb 18, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Allow linker to perform deadcode elimination for programs using fx
3 participants