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

Refactor usages of std::ostringstream #912

Merged
merged 10 commits into from
Dec 1, 2023
Merged

Conversation

Baltoli
Copy link
Contributor

@Baltoli Baltoli commented Dec 1, 2023

A common pattern in the backend's code is to do the following:

std::ostringstream out;
pattern->print(out);
do_something(out.str());

In #911, we introduced a helper function ast_to_string that wraps this common pattern up; this PR follows up that change by mechanically refactoring the remainder of the codebase to use the helper. After the change, the above code would be:

do_something(ast_to_string(*pattern));

Each commit in the PR (bar the first) applies the same conceptual refactoring to a single file; no actual behavioural changes other than in the first commit are implemented, and so this should be an easy PR to review.

In future work, I'd like to further clean up this code and make better use of fmt across the codebase, but for now this is a useful self-contained change to make.

Copy link
Contributor

@gtrepta gtrepta left a comment

Choose a reason for hiding this comment

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

LGTM

@rv-jenkins rv-jenkins merged commit c75fe25 into master Dec 1, 2023
5 checks passed
@rv-jenkins rv-jenkins deleted the ostringstream-refactor branch December 1, 2023 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants