Skip to content

Use {int}::to_le_bytes in WriteBytesExt#204

Merged
fintelia merged 1 commit into
image-rs:masterfrom
bushrat011899:to_le_bytes
May 18, 2025
Merged

Use {int}::to_le_bytes in WriteBytesExt#204
fintelia merged 1 commit into
image-rs:masterfrom
bushrat011899:to_le_bytes

Conversation

@bushrat011899
Copy link
Copy Markdown
Contributor

Objective

WriteBytesExt currently uses a hand-rolled bit-shifting algorithm to divide and conquer unsized integers into little-endian bytes, before passing them to Write::write_all. While the implementation is correct, core provides {int}::to_le_bytes, which may optimise better (since it more clearly conveys intent to the optimiser), and is definitely more likely to be tested and maintained.

Solution

  • Switched to {int}::to_le_bytes for the implementations of WriteBytesExt::write_le

@bushrat011899
Copy link
Copy Markdown
Contributor Author

Like #203, I can't replicate the CI failure locally. Any ideas?

@bushrat011899
Copy link
Copy Markdown
Contributor Author

See #206 for CI failure cause and possible fix.

@fintelia fintelia merged commit 008596b into image-rs:master May 18, 2025
14 of 26 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.

2 participants