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

Trim leading/trailing spaces after topformflat #165

Merged
merged 1 commit into from
Jan 22, 2025

Conversation

emaxx-google
Copy link
Contributor

@emaxx-google emaxx-google commented Jan 22, 2025

This reduces the overhead slightly and prevents the files from
growing noticeably when the lines passes start. This fixes #163.

Note that this new logic has a safeguard that falls back to the
previous behavior (which takes the topformflat's output as-is) in
case the interestingness script starts failing.

):
backup.close()
with open(test_case) as in_file:
try:
cmd = [self.external_programs['topformflat'], self.arg]
proc = subprocess.run(cmd, stdin=in_file, capture_output=True, text=True)
with subprocess.Popen(cmd, stdin=in_file, stdout=subprocess.PIPE, text=True) as proc:
Copy link
Contributor Author

@emaxx-google emaxx-google Jan 22, 2025

Choose a reason for hiding this comment

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

I took the liberty to change this to read stdout per line, instead of accumulating everything in the memory. It's not a big speedup (transform and __count_instances load the whole file anyway), but the optimization felt easily doable...

This reduces the overhead slightly and prevents the files from
growing noticeably when the lines passes start.

Note that this new logic has a safeguard that falls back to the
previous behavior (which takes the topformflat's output as-is) in
case the interestingness script starts failing.
@emaxx-google emaxx-google marked this pull request as ready for review January 22, 2025 09:22
@emaxx-google emaxx-google changed the title [to be rebased] Trim leading/trailing spaces after topformflat Trim leading/trailing spaces after topformflat Jan 22, 2025
@marxin marxin merged commit eac3b8c into marxin:master Jan 22, 2025
11 checks passed
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.

Trimming spaces after topformflat?
2 participants