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

Utilities/wc: Seek the input file(s) if only -c is passed #24499

Merged
merged 1 commit into from
Jun 29, 2024

Conversation

supercomputer7
Copy link
Member

@supercomputer7 supercomputer7 commented May 31, 2024

If the user only wants to get the byte count of a set of files, then for each file we can simply seek it to get the byte count instead of iterating over all the bytes.

Revives #21961. The original PR had a bug in which -c wouldn't be able to handle standard input stream, but now I added a condition to handle ESPIPE error as well.

@github-actions github-actions bot added the 👀 pr-needs-review PR needs review from a maintainer or community member label May 31, 2024
@supercomputer7 supercomputer7 force-pushed the wc-bytes-only-seek branch 2 times, most recently from 99e9120 to cb86853 Compare June 1, 2024 10:14
@supercomputer7 supercomputer7 changed the title wc: Seek the input file(s) if only -c is passed Utilities/wc: Seek the input file(s) if only -c is passed Jun 1, 2024
Copy link

stale bot commented Jun 26, 2024

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions!

@stale stale bot added the stale label Jun 26, 2024
Userland/Utilities/wc.cpp Outdated Show resolved Hide resolved
Userland/Utilities/wc.cpp Outdated Show resolved Hide resolved
If the user only wants to get the byte count of a set of files, then for
each file we can simply seek it to get the byte count instead of
iterating over all the bytes.
@timschumi timschumi merged commit 96efa81 into SerenityOS:master Jun 29, 2024
12 checks passed
@github-actions github-actions bot removed the 👀 pr-needs-review PR needs review from a maintainer or community member label Jun 29, 2024
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.

None yet

3 participants