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
Switched to generic endian swap #2380
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #2380 +/- ##
==========================================
+ Coverage 27.15% 31.61% +4.46%
==========================================
Files 228 198 -30
Lines 19637 14318 -5319
Branches 4710 2672 -2038
==========================================
- Hits 5332 4527 -805
+ Misses 13826 9644 -4182
+ Partials 479 147 -332
... and 75 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
If I understand correct, this PR would make sure bytes always get swapped around but what about the case where the machine's endianness matches network endianness? In that case we don't need to swap bytes around but this would seemingly still swap them. |
This inspired me to write tests that make sure we're using the correct network ordering. Let me know if you can run your code with these tests and see if anything fails. |
I'm not convinced SFML should be doing any reordering - in the vast majority of cases it's going to be little endian machines on both sides, using SFML sockets. In which cases the conversion is just redundant extra work for both sides I think the only use case this benefits would be people communicating with other services they have no control over, in which case they can still do the conversion themselves? At best this should be optional, and off by default |
Where can I access these tests? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of these functions are collapsing down to nearly identical code. I wonder if this new pattern means we can replace a lot of these function overloads with a template and cut out hundreds of lines of code.
d567cfe
to
0b5941c
Compare
I was thinking about that. Is there a consistent pattern that can be applied to character strings? Those are also not converted to network byte order. |
Each character is one byte which means the endianness doesn't really matter. If each character is >1 byte then I'd expect each character to get its bytes rearranged but not to reverse the string itself. |
0b5941c
to
0d6e35f
Compare
I'm going to pause on the PR feedback until some other maintainers can weigh in on whether they like reimplementing |
I imagine that would be the subject of a separate PR |
I see it as part of justifying this PR. It's easier to get this approved and merged this if it also means getting to delete huge swaths of code. |
Any sense of when and how the maintainers want to move forward? |
b78b682
to
410f178
Compare
Sorry I'm not sure. |
410f178
to
92f198f
Compare
9eb32b1
to
d7efdbb
Compare
e86d1d4
to
778c998
Compare
Added missing <array> header Addressed review comments Restricted templated swaps to Packet Made variable names more descriptive per review Initial implementation of templated operators Changed to if constexpr to work around C4127 error Conformed initialization style Removed unused variable
778c998
to
508603c
Compare
Thanks a lot for making a contribution to SFML! 🙂
Before you create the pull request, we ask you to check the follow boxes. (For small changes not everything needs to ticked, but the more the better!)
Description
Switched to use generic (templated) endian swap method that I've used successfully in the past.
This PR is related to the issue #2290
Tasks
How to test this PR?
Extended the
Packet
stream tests to includefloat
anddouble