mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-11-25 16:34:00 +00:00
tidying
This commit is contained in:
parent
5c3f6a0753
commit
c28ecb0486
@ -15,9 +15,9 @@ public class Huffman extends AbstractFile
|
|||||||
private static final byte[] mask = { 2, 1 };
|
private static final byte[] mask = { 2, 1 };
|
||||||
private static final int[] offset = { RIGHT, LEFT };
|
private static final int[] offset = { RIGHT, LEFT };
|
||||||
|
|
||||||
private int bitNo;
|
private byte depth;
|
||||||
private int msgPtr;
|
private int msgPtr;
|
||||||
private int currentByte;
|
private byte currentByte;
|
||||||
private byte[] message;
|
private byte[] message;
|
||||||
|
|
||||||
private String bufferContents;
|
private String bufferContents;
|
||||||
@ -30,7 +30,7 @@ public class Huffman extends AbstractFile
|
|||||||
public String decodeMessage (byte[] message)
|
public String decodeMessage (byte[] message)
|
||||||
{
|
{
|
||||||
this.message = message;
|
this.message = message;
|
||||||
bitNo = 0;
|
depth = 0;
|
||||||
msgPtr = 0;
|
msgPtr = 0;
|
||||||
currentByte = 0;
|
currentByte = 0;
|
||||||
|
|
||||||
@ -48,14 +48,11 @@ public class Huffman extends AbstractFile
|
|||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (bitNo-- == 0)
|
if ((depth++ & 0x07) == 0) // every 8th bit
|
||||||
{
|
currentByte = message[msgPtr++]; // get a new byte
|
||||||
bitNo += 8;
|
|
||||||
currentByte = message[msgPtr++] & 0xFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
int currentBit = currentByte % 2; // get the next bit to process
|
int currentBit = currentByte & 0x01; // get the next bit to process
|
||||||
currentByte /= 2;
|
currentByte >>= 1; // and discard it
|
||||||
|
|
||||||
// use currentBit to determine whether to use the left or right node
|
// use currentBit to determine whether to use the left or right node
|
||||||
byte nodeValue = buffer[treePtr + offset[currentBit]];
|
byte nodeValue = buffer[treePtr + offset[currentBit]];
|
||||||
|
Loading…
Reference in New Issue
Block a user