mirror of
https://github.com/revanced/smali.git
synced 2025-05-08 02:14:32 +02:00
minor optimizations in ByteArrayInput
git-svn-id: https://smali.googlecode.com/svn/trunk@686 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
parent
1f29ee7351
commit
bba8645009
@ -78,66 +78,43 @@ public class ByteArrayInput
|
|||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
public byte readByte() {
|
public byte readByte() {
|
||||||
int readAt = cursor;
|
return data[cursor++];
|
||||||
int end = readAt + 1;
|
|
||||||
|
|
||||||
if (end > data.length) {
|
|
||||||
throwBounds();
|
|
||||||
}
|
|
||||||
|
|
||||||
cursor = end;
|
|
||||||
return data[readAt];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
public int readShort() {
|
public int readShort() {
|
||||||
int readAt = cursor;
|
int readAt = cursor;
|
||||||
int end = readAt + 2;
|
int result = ((data[readAt++] & 0xff) +
|
||||||
|
((data[readAt++] & 0xff) << 8));
|
||||||
if (end > data.length) {
|
cursor = readAt;
|
||||||
throwBounds();
|
return result;
|
||||||
}
|
|
||||||
|
|
||||||
cursor = end;
|
|
||||||
return ((data[readAt] & 0xff) +
|
|
||||||
((data[readAt + 1] & 0xff) << 8));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
public int readInt() {
|
public int readInt() {
|
||||||
int readAt = cursor;
|
int readAt = cursor;
|
||||||
int end = readAt + 4;
|
int result = (data[readAt++] & 0xff) +
|
||||||
|
((data[readAt++] & 0xff) << 8) +
|
||||||
if (end > data.length) {
|
((data[readAt++] & 0xff) << 16) +
|
||||||
throwBounds();
|
((data[readAt++] & 0xff) << 24);
|
||||||
}
|
cursor = readAt;
|
||||||
|
return result;
|
||||||
cursor = end;
|
|
||||||
return (data[readAt] & 0xff) +
|
|
||||||
((data[readAt + 1] & 0xff) << 8) +
|
|
||||||
((data[readAt + 2] & 0xff) << 16) +
|
|
||||||
((data[readAt + 3] & 0xff) << 24);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
public long readLong() {
|
public long readLong() {
|
||||||
int readAt = cursor;
|
int readAt = cursor;
|
||||||
int end = readAt + 8;
|
|
||||||
|
|
||||||
if (end > data.length) {
|
long result = (data[readAt++] & 0xffL) |
|
||||||
throwBounds();
|
((data[readAt++] & 0xffL) << 8) |
|
||||||
}
|
((data[readAt++] & 0xffL) << 16) |
|
||||||
|
((data[readAt++] & 0xffL) << 24) |
|
||||||
cursor = end;
|
((data[readAt++] & 0xffL) << 32) |
|
||||||
|
((data[readAt++] & 0xffL) << 40) |
|
||||||
return (data[readAt] & 0xffL) |
|
((data[readAt++] & 0xffL) << 48) |
|
||||||
((data[readAt + 1] & 0xffL) << 8) |
|
((data[readAt++] & 0xffL) << 58);
|
||||||
((data[readAt + 2] & 0xffL) << 16) |
|
cursor = readAt;
|
||||||
((data[readAt + 3] & 0xffL) << 24) |
|
return result;
|
||||||
((data[readAt + 4] & 0xffL) << 32) |
|
|
||||||
((data[readAt + 5] & 0xffL) << 40) |
|
|
||||||
((data[readAt + 6] & 0xffL) << 48) |
|
|
||||||
((data[readAt + 7] & 0xffL) << 58);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -300,9 +277,6 @@ public class ByteArrayInput
|
|||||||
int startPosition = cursor;
|
int startPosition = cursor;
|
||||||
while (data[cursor] != 0) {
|
while (data[cursor] != 0) {
|
||||||
cursor++;
|
cursor++;
|
||||||
if (cursor >= data.length) {
|
|
||||||
throwBounds();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
int byteCount = cursor - startPosition;
|
int byteCount = cursor - startPosition;
|
||||||
|
|
||||||
@ -314,24 +288,12 @@ public class ByteArrayInput
|
|||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
public void skipBytes(int count) {
|
public void skipBytes(int count) {
|
||||||
int end = cursor + count;
|
cursor += count;
|
||||||
|
|
||||||
if (end > data.length) {
|
|
||||||
throwBounds();
|
|
||||||
}
|
|
||||||
|
|
||||||
cursor = end;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
public void alignTo(int alignment) {
|
public void alignTo(int alignment) {
|
||||||
int end = AlignmentUtils.alignOffset(cursor, alignment);
|
cursor = AlignmentUtils.alignOffset(cursor, alignment);
|
||||||
|
|
||||||
if (end > data.length) {
|
|
||||||
throwBounds();
|
|
||||||
}
|
|
||||||
|
|
||||||
cursor = end;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user