devkitPro / wut

Let's try to make a Wii U Toolchain / SDK for creating rpx/rpl.
zlib License
244 stars 52 forks source link

wutdevoptab: check size of a read/write before checking the buffer alignment to reduce the read/write calls #273

Closed Maschell closed 2 years ago

Maschell commented 2 years ago

If the size is < 0x40 we need to use the aligned buffer anyway, so we check this first to avoid splitting the call up into multiple calls.

Example: With the previous implementation writing 26 bytes from buffer 0x10000038, will result two write calls. First call writes 8 bytes (buffer not aligned => MIN(size, 0x40 - ((uintptr_t) ptr & 0x3F)), the other one the remaining 18 bytes (buffer is now aligned, but size is now < 0x40).

With the new implementation the same operation (write 26 bytes from 0x10000038) would just result in one single 26 bytes (because size < 0x40 is checked first) call.