Slightly simplify code.
This commit is contained in:
parent
82f358ff2a
commit
f8e5127d49
@ -565,7 +565,7 @@ static int
|
|||||||
Pred1Compress(node_p node, u_char *source, u_char *dest, int len)
|
Pred1Compress(node_p node, u_char *source, u_char *dest, int len)
|
||||||
{
|
{
|
||||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||||
int i, bitmask;
|
int i;
|
||||||
u_char flags;
|
u_char flags;
|
||||||
u_char *flagdest, *orgdest;
|
u_char *flagdest, *orgdest;
|
||||||
|
|
||||||
@ -573,10 +573,10 @@ Pred1Compress(node_p node, u_char *source, u_char *dest, int len)
|
|||||||
while (len) {
|
while (len) {
|
||||||
flagdest = dest++;
|
flagdest = dest++;
|
||||||
flags = 0; /* All guesses are wrong initially. */
|
flags = 0; /* All guesses are wrong initially. */
|
||||||
for (bitmask = 1, i = 0; i < 8 && len; i++, bitmask <<= 1) {
|
for (i = 0; i < 8 && len; i++) {
|
||||||
if (priv->GuessTable[priv->Hash] == *source)
|
if (priv->GuessTable[priv->Hash] == *source)
|
||||||
/* Guess was right - don't output. */
|
/* Guess was right - don't output. */
|
||||||
flags |= bitmask;
|
flags |= (1 << i);
|
||||||
else {
|
else {
|
||||||
/* Guess wrong, output char. */
|
/* Guess wrong, output char. */
|
||||||
priv->GuessTable[priv->Hash] = *source;
|
priv->GuessTable[priv->Hash] = *source;
|
||||||
@ -600,17 +600,17 @@ static int
|
|||||||
Pred1Decompress(node_p node, u_char *source, u_char *dest, int slen, int dlen)
|
Pred1Decompress(node_p node, u_char *source, u_char *dest, int slen, int dlen)
|
||||||
{
|
{
|
||||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||||
int i, bitmask;
|
int i;
|
||||||
u_char flags, *orgdest;
|
u_char flags, *orgdest;
|
||||||
|
|
||||||
orgdest = dest;
|
orgdest = dest;
|
||||||
while (slen) {
|
while (slen) {
|
||||||
flags = *source++;
|
flags = *source++;
|
||||||
slen--;
|
slen--;
|
||||||
for (i = 0, bitmask = 1; i < 8; i++, bitmask <<= 1) {
|
for (i = 0; i < 8; i++, flags >>= 1) {
|
||||||
if (dlen <= 0)
|
if (dlen <= 0)
|
||||||
return(-1);
|
return(-1);
|
||||||
if (flags & bitmask)
|
if (flags & 0x01)
|
||||||
/* Guess correct */
|
/* Guess correct */
|
||||||
*dest = priv->GuessTable[priv->Hash];
|
*dest = priv->GuessTable[priv->Hash];
|
||||||
else {
|
else {
|
||||||
|
Loading…
Reference in New Issue
Block a user