Commit 07374958 by Rudolf

Rewrite tree encoding

This is simpler and less error prone. Just compare right->ch and if it doesn't
match, check if next left is the last left.
parent bb50e02d
Showing with 8 additions and 20 deletions
...@@ -100,26 +100,14 @@ static int write_entry(struct BIT_BUFFER *bitbuf, struct tree *parent, ...@@ -100,26 +100,14 @@ static int write_entry(struct BIT_BUFFER *bitbuf, struct tree *parent,
left = parent->left; left = parent->left;
right = parent->right; right = parent->right;
if (c != 0) { if (right->ch == c) {
if (left->ch == c) { bit = 1;
bit = 0; bb_write(bitbuf, &bit, 1);
bb_write(bitbuf, &bit, 1); break;
break; } else if (left->left == NULL) {
} else if (right->ch == c) { bit = 0;
bit = 1; bb_write(bitbuf, &bit, 1);
bb_write(bitbuf, &bit, 1); break;
break;
}
} else {
if (left->left == NULL) {
bit = 0;
bb_write(bitbuf, &bit, 1);
break;
} else if (right->ch == c) {
bit = 1;
bb_write(bitbuf, &bit, 1);
break;
}
} }
bit = 0; bit = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment