aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2018-01-09 00:13:11 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2018-01-09 00:13:11 +0530
commitf6fd15e088f22a90a9d3f01dd8436a507fe5febc (patch)
treee4a7d6eaa83fb1ae769946e3efa16170a7c8dc9c
parent77fec499cb71069e58c525f07e95de531763a933 (diff)
downloadnnn-f6fd15e088f22a90a9d3f01dd8436a507fe5febc.tar.gz
Explicitly optimize modulo ops
-rw-r--r--nnn.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/nnn.c b/nnn.c
index c7e5d48..397ccd1 100644
--- a/nnn.c
+++ b/nnn.c
@@ -384,7 +384,7 @@ xstrlcpy(char *dest, const char *src, size_t n)
s = (ulong *)src;
d = (ulong *)dest;
blocks = n >> _WSHIFT;
- n -= (blocks << _WSHIFT);
+ n &= lsize - 1;
while (blocks) {
*d = *s;
@@ -1278,7 +1278,6 @@ coolsize(off_t size)
static const char * const U = "BKMGTPEZY";
static char size_buf[12]; /* Buffer to hold human readable size */
static int i;
- static off_t tmp;
static long double rem;
static const double div_2_pow_10 = 1.0 / 1024.0;
@@ -1287,9 +1286,8 @@ coolsize(off_t size)
rem = 0;
while (size > 1024) {
- tmp = size;
+ rem = size & (0x3FF); /* 1024 - 1 = 0x3FF */
size >>= 10;
- rem = tmp - (size << 10);
++i;
}