Skip to content

od: simplify a match in input_decoder.rs - #14006

Merged
cakebaker merged 2 commits into
uutils:mainfrom
Devel08:input-decoder-simplify-match
Aug 19, 2026
Merged

od: simplify a match in input_decoder.rs#14006
cakebaker merged 2 commits into
uutils:mainfrom
Devel08:input-decoder-simplify-match

Conversation

@Devel08

@Devel08 Devel08 commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@Devel08

Devel08 commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

@xtqqczze what do you think

@github-actions

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/cut/bounded-memory (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/misc/io-errors (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/retry (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tail/tail-n0f (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/cut/cut-huge-range is now being skipped but was previously passing.
Note: The gnu test tests/printf/printf-surprise is now being skipped but was previously passing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The map feels a bit unusual here since we’re updating two fields as a side effect.

How about using the ? operator to return early instead?

    let (n, p) = self
        .input
        .peek_read(self.data.as_mut_slice(), self.reserved_peek_length)?;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

so like that?

    pub fn peek_read(&mut self) -> io::Result<MemoryDecoder<'_>> {
        let (n, p) = self
            .input
            .peek_read(self.data.as_mut_slice(), self.reserved_peek_length)?;
        self.used_normal_length = n;
        self.used_peek_length = p;
        Ok(MemoryDecoder {
            data: &mut self.data,
            used_normal_length: self.used_normal_length,
            used_peek_length: self.used_peek_length,
            byte_order: self.byte_order,
        })
    }

@cakebaker
cakebaker merged commit b2a617e into uutils:main Aug 19, 2026
169 checks passed
@cakebaker

Copy link
Copy Markdown
Contributor

Thanks!

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.

3 participants