aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2015-07-10 01:23:54 -0500
committerRob Landley <rob@landley.net>2015-07-10 01:23:54 -0500
commit747e74852b982f8b2c54dc3e3650352843a6bede (patch)
tree9eaf60354705957353213028da6a010e0b0c87ae /toys
parent78beadd60b81c0b3c92eca38890983a672dbfd93 (diff)
downloadtoybox-747e74852b982f8b2c54dc3e3650352843a6bede.tar.gz
Rename a function to be more obvious, and factor out a repeated calculation
the compiler was almost certainly retaining in a register anyway.
Diffstat (limited to 'toys')
-rw-r--r--toys/pending/compress.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/toys/pending/compress.c b/toys/pending/compress.c
index 45251fcc..1749ee4f 100644
--- a/toys/pending/compress.c
+++ b/toys/pending/compress.c
@@ -232,11 +232,13 @@ void bitbuf_put(struct bitbuf *bb, int data, int len)
}
}
-static void data_crc(char sym)
+static void output_byte(char sym)
{
- TT.data[TT.pos++ & 32767] = sym;
+ int pos = TT.pos++ & 32767;
- if (!(TT.pos & 32767)) {
+ TT.data[pos] = sym;
+
+ if (!pos) {
xwrite(TT.outfd, TT.data, 32768);
if (TT.crcfunc) TT.crcfunc(TT.data, 32768);
}
@@ -323,7 +325,7 @@ static void inflate(struct bitbuf *bb)
// dump bytes until done or end of current bitbuf contents
if (bblen > len) bblen = len;
pos = bblen;
- while (pos--) data_crc(*(p++));
+ while (pos--) output_byte(*(p++));
bitbuf_skip(bb, bblen << 3);
len -= bblen;
}
@@ -383,7 +385,7 @@ static void inflate(struct bitbuf *bb)
int sym = huff_and_puff(bb, lithuff);
// Literal?
- if (sym < 256) data_crc(sym);
+ if (sym < 256) output_byte(sym);
// Copy range?
else if (sym > 256) {
@@ -395,7 +397,7 @@ static void inflate(struct bitbuf *bb)
dist = TT.distbase[sym] + bitbuf_get(bb, TT.distbits[sym]);
sym = TT.pos & 32767;
- while (len--) data_crc(TT.data[(TT.pos-dist) & 32767]);
+ while (len--) output_byte(TT.data[(TT.pos-dist) & 32767]);
// End of block
} else break;