From: Alan Cox Date: Wed, 5 Nov 2014 19:20:56 +0000 (+0000) Subject: syscall_other: optimisations X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=04db32e9b7ae9358a6348edd022c976346a13d5c;p=FUZIX.git syscall_other: optimisations Cache the inode calculation in execve, otherwise each loop pass must recompute it as the compiler can't know the functions don't touch it. Add a couple of staticfasts --- diff --git a/Kernel/syscall_other.c b/Kernel/syscall_other.c index e6186212..b14276ac 100644 --- a/Kernel/syscall_other.c +++ b/Kernel/syscall_other.c @@ -27,7 +27,7 @@ put inside itself! int16_t _rename(void) { - inoptr srci, srcp, dsti, dstp; + staticfast inoptr srci, srcp, dsti, dstp; char fname[FILENAME_LEN + 1]; int ret = -1; @@ -394,6 +394,7 @@ int16_t _execve(void) int j; uint16_t top = (uint16_t)ramtop; uint8_t c; + uint16_t blocks; kputs("execve\n"); @@ -547,7 +548,12 @@ int16_t _execve(void) * will still be cached. - Hat tip to Steve Hosgood's OMU for that trick */ progptr = PROGBASE + 512; // we copied the first block already - for (blk = 1; blk <= ino->c_node.i_size >> 9; ++blk) { + + /* Compute this once otherwise each loop we must recalculate this + as the compiler isn't entitled to assume the loop didn't change it */ + blocks = ino->c_node.i_size >> 9; + + for (blk = 1; blk <= blocks; ++blk) { buf = bread(ino->c_dev, bmap(ino, blk, 1), 0); uput(buf, progptr, 512); bufdiscard((bufptr) buf);