Skip to content

Commit

Permalink
simplified incrementation
Browse files Browse the repository at this point in the history
  • Loading branch information
yassine committed Feb 24, 2020
1 parent 9cae396 commit 056bf15
Showing 1 changed file with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@ public int readInt() throws AvroCodecException {
byte current;
int shift = 0;
do {
current = data[position];
current = data[position++];
result |= (current & 0x7F) << shift;
if ( (current & 0x80) == 0 ) {
cursor = position + 1;
cursor = position;
return (result >>> 1) ^ -(result & 1);
}
shift += 7;
position++;
} while (shift < 32);
throw AvroCodecException.API.unexpectedNumber();
}
Expand All @@ -55,25 +54,23 @@ public long readLong() throws AvroCodecException {
byte current;
int shift = 0;
do {
current = data[position];
current = data[position++];
result |= (current & 0x7F) << shift;
if ((current & 0x80) == 0) {
cursor = position + 1;
cursor = position;
return (result >>> 1) ^ -(result & 1);
}
shift += 7;
position++;
} while (shift < 25);
//need to cast to long
do {
current = data[position];
current = data[position++];
result |= ((long) (current & 0x7F)) << shift;
if ((current & 0x80) == 0) {
cursor = position + 1;
cursor = position;
return (result >>> 1) ^ -(result & 1);
}
shift += 7;
position++;
} while (shift < 64);
throw AvroCodecException.API.unexpectedNumber();
}
Expand Down

0 comments on commit 056bf15

Please sign in to comment.