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

Overhaul endian handling in ByteBuffer and FastNBT #5543

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Jan 17, 2024

  1. Overhaul endian handling in ByteBuffer and FastNBT

    Rather than juggling "swapped" and "unswapped" versions of integers, different library functions, #defines, etc., simply always read everything byte-by-byte.
    
    This works regardless of host CPU endian, got optimised down to either a normal load or a byteswap on every compiler I tested - only 1 instruction on most CPU architectures.
    
    This commit introduces a "Bytes" array type to keep endian-sensitive data seperate from host data, alongside the needed C++ template machinery for it to work seamlessly. This approach is a little bit safer as well since you get length- and type-checking for most callsites.
    ashquarky committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    928fddc View commit details
    Browse the repository at this point in the history