From 0af58eb9bb6cdbe414432f3e36ccc2490e26e398 Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Thu, 16 Oct 2014 14:39:45 +0200 Subject: [PATCH] VarInt patch by "bake3978", taken from https://code.google.com/p/bitcoinj/issues/detail?id=582 Deleted unnecessary codes; long val; ... val = first; ... this.value = val; -> this.value = first; --- core/src/main/java/org/bitcoinj/core/VarInt.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/org/bitcoinj/core/VarInt.java b/core/src/main/java/org/bitcoinj/core/VarInt.java index 0ba02703..1e4597bc 100644 --- a/core/src/main/java/org/bitcoinj/core/VarInt.java +++ b/core/src/main/java/org/bitcoinj/core/VarInt.java @@ -34,27 +34,25 @@ public class VarInt { // Bitcoin has its own varint format, known in the C++ source as "compact size". public VarInt(byte[] buf, int offset) { int first = 0xFF & buf[offset]; - long val; if (first < 253) { // 8 bits. - val = first; + this.value = first; originallyEncodedSize = 1; } else if (first == 253) { // 16 bits. - val = (0xFF & buf[offset + 1]) | ((0xFF & buf[offset + 2]) << 8); + this.value = (0xFF & buf[offset + 1]) | ((0xFF & buf[offset + 2]) << 8); originallyEncodedSize = 3; } else if (first == 254) { // 32 bits. - val = Utils.readUint32(buf, offset + 1); + this.value = Utils.readUint32(buf, offset + 1); originallyEncodedSize = 5; } else { // 64 bits. - val = Utils.readUint32(buf, offset + 1) | (Utils.readUint32(buf, offset + 5) << 32); + this.value = Utils.readUint32(buf, offset + 1) | (Utils.readUint32(buf, offset + 5) << 32); originallyEncodedSize = 9; } - this.value = val; } - + /** * Gets the number of bytes used to encode this originally if deserialized from a byte array. * Otherwise returns the minimum encoded size