what-the-bank/sources/o/MZr.java

115 lines
2.9 KiB
Java

package o;
import com.google.common.primitives.UnsignedBytes;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.Iterator;
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public final class MZr extends InputStream {
private long a;
private ByteBuffer b;
private byte[] c;
private int d;
private int e;
private int g = 0;
private int h;
private Iterator<ByteBuffer> i;
private boolean j;
/* JADX INFO: Access modifiers changed from: package-private */
public MZr(Iterable<ByteBuffer> iterable) {
this.i = iterable.iterator();
for (ByteBuffer byteBuffer : iterable) {
this.g++;
}
this.h = -1;
if (c()) {
return;
}
this.b = MTP.d;
this.h = 0;
this.d = 0;
this.a = 0L;
}
private boolean c() {
this.h++;
if (!this.i.hasNext()) {
return false;
}
ByteBuffer next = this.i.next();
this.b = next;
this.d = next.position();
if (this.b.hasArray()) {
this.j = true;
this.c = this.b.array();
this.e = this.b.arrayOffset();
} else {
this.j = false;
this.a = vqr.d(this.b);
this.c = null;
}
return true;
}
@Override // java.io.InputStream
public final int read() throws IOException {
if (this.h == this.g) {
return -1;
}
if (this.j) {
byte[] bArr = this.c;
int i = this.d;
byte b = bArr[this.e + i];
int i2 = i + 1;
this.d = i2;
if (i2 == this.b.limit()) {
c();
}
return b & UnsignedBytes.MAX_VALUE;
}
byte d = vqr.d(this.d + this.a);
int i3 = this.d + 1;
this.d = i3;
if (i3 == this.b.limit()) {
c();
}
return d & UnsignedBytes.MAX_VALUE;
}
@Override // java.io.InputStream
public final int read(byte[] bArr, int i, int i2) throws IOException {
if (this.h == this.g) {
return -1;
}
int limit = this.b.limit();
int i3 = this.d;
int i4 = limit - i3;
if (i2 > i4) {
i2 = i4;
}
if (this.j) {
System.arraycopy(this.c, i3 + this.e, bArr, i, i2);
int i5 = this.d + i2;
this.d = i5;
if (i5 == this.b.limit()) {
c();
}
} else {
int position = this.b.position();
this.b.position(this.d);
this.b.get(bArr, i, i2);
this.b.position(position);
int i6 = this.d + i2;
this.d = i6;
if (i6 == this.b.limit()) {
c();
}
}
return i2;
}
}