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

Replace as_bytes with safe code #39

Merged
merged 1 commit into from Jan 21, 2021
Merged

Replace as_bytes with safe code #39

merged 1 commit into from Jan 21, 2021

Conversation

niklasf
Copy link
Contributor

@niklasf niklasf commented Jan 17, 2021

Is it intentional that the conversion in as_bytes() depends on the endianness?

If yes, there should maybe be a comment mentioning it.

I think it is not, so it may be best to replace it with a (not much longer) version without unsafe.

Nevermind the endianness question. I guess x86 is just always little endian. I believe it's still best to avoid unsafe code, when the safe version is not significantly longer or slower.

@gz
Copy link
Owner

@gz gz commented Jan 21, 2021

This makes total sense, thanks for submitting this!

@gz gz merged commit 582b6d7 into gz:master Jan 21, 2021
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

2 participants