Skip to content

Refactor usages of std::ostringstream#912

Merged
rv-jenkins merged 10 commits into
masterfrom
ostringstream-refactor
Dec 1, 2023
Merged

Refactor usages of std::ostringstream#912
rv-jenkins merged 10 commits into
masterfrom
ostringstream-refactor

Conversation

@Baltoli
Copy link
Copy Markdown
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
Copy Markdown
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
@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