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

This commit is contained in:
Maschell
2022-09-20 19:10:02 +02:00
committed by fincs
parent 2c331d22ce
commit ec4a7eae1e
2 changed files with 8 additions and 8 deletions

View File

@@ -28,13 +28,13 @@ ssize_t __wut_fs_read(struct _reent *r, void *fd, char *ptr, size_t len) {
uint8_t *tmp = (uint8_t *) ptr;
size_t size = len - bytesRead;
if ((uintptr_t) ptr & 0x3F) {
if (size < 0x40) {
// read partial cache-line back-end
tmp = alignedBuffer;
} else if ((uintptr_t) ptr & 0x3F) {
// read partial cache-line front-end
tmp = alignedBuffer;
size = MIN(size, 0x40 - ((uintptr_t) ptr & 0x3F));
} else if (size < 0x40) {
// read partial cache-line back-end
tmp = alignedBuffer;
} else {
// read whole cache lines
size &= ~0x3F;

View File

@@ -32,13 +32,13 @@ ssize_t __wut_fs_write(struct _reent *r, void *fd, const char *ptr, size_t len)
uint8_t *tmp = (uint8_t *) ptr;
size_t size = len - bytesWritten;
if ((uintptr_t) ptr & 0x3F) {
if (size < 0x40) {
// write partial cache-line back-end
tmp = alignedBuffer;
} else if ((uintptr_t) ptr & 0x3F) {
// write partial cache-line front-end
tmp = alignedBuffer;
size = MIN(size, 0x40 - ((uintptr_t) ptr & 0x3F));
} else if (size < 0x40) {
// write partial cache-line back-end
tmp = alignedBuffer;
} else {
// write whole cache lines
size &= ~0x3F;