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

Reduce use of carriage returns #97

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Reduce use of carriage returns #97

wants to merge 3 commits into from

Conversation

pfee
Copy link

@pfee pfee commented Apr 15, 2022

Issue #53 relates to unwanted carriage return characters.

Their purpose it to redraw an existing line. However they're only needed on occasions where the line needs output more than once. If there's only one version of the line to output, then the \r characters can be avoided.

Since print_page_residency_chart() was only ever called with the first
parameter set to stdout, this API flexibility is not used.  Simplify API
until it's needed by removing the first parameter.
This makes it easier to reason about function, knowing that it's never
called outside this compilation unit.
The carriage return is not needed the first time
print_page_residency_chart() is called.  By moving \r printing to the
caller, it knows which is the first time.

Only within the o_touch loop is print_page_residency_chart() called
multiple times, so only within that loop is \r necessary.

The final call to print_page_residency_chart() has been removed since it
would print identical content to the previous time it was called,
whether than be within the o_touch loop or not.  Hence it has been
removed as all that's needed is to terminate the line with \n.
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