package com.tapjoy.internal; import java.io.Closeable; import java.io.EOFException; import java.io.Flushable; import java.nio.charset.Charset; /* loaded from: classes4.dex */ public final class l implements Closeable, Flushable, Cloneable { public b1 a; public long b; @Override // java.io.Closeable, java.lang.AutoCloseable public final void close() { } public final boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof l)) { return false; } l lVar = (l) obj; long j = this.b; if (j != lVar.b) { return false; } long j2 = 0; if (j == 0) { return true; } b1 b1Var = this.a; b1 b1Var2 = lVar.a; int i = b1Var.b; int i2 = b1Var2.b; while (j2 < this.b) { long min = Math.min(b1Var.c - i, b1Var2.c - i2); int i3 = 0; while (i3 < min) { int i4 = i + 1; int i5 = i2 + 1; if (b1Var.a[i] != b1Var2.a[i2]) { return false; } i3++; i = i4; i2 = i5; } if (i == b1Var.c) { b1Var = b1Var.f; i = b1Var.b; } if (i2 == b1Var2.c) { b1Var2 = b1Var2.f; i2 = b1Var2.b; } j2 += min; } return true; } @Override // java.io.Flushable public final void flush() { } /* renamed from: clone, reason: merged with bridge method [inline-methods] */ public final l m3723clone() { l lVar = new l(); if (this.b == 0) { return lVar; } b1 b1Var = new b1(this.a); lVar.a = b1Var; b1Var.g = b1Var; b1Var.f = b1Var; for (b1 b1Var2 = this.a.f; b1Var2 != this.a; b1Var2 = b1Var2.f) { b1 b1Var3 = lVar.a.g; b1 b1Var4 = new b1(b1Var2); b1Var3.getClass(); b1Var4.g = b1Var3; b1Var4.f = b1Var3.f; b1Var3.f.g = b1Var4; b1Var3.f = b1Var4; } lVar.b = this.b; return lVar; } public final String toString() { long j = this.b; if (j <= 2147483647L) { int i = (int) j; return (i == 0 ? m.e : new d1(this, i)).toString(); } throw new IllegalArgumentException("size > Integer.MAX_VALUE: " + this.b); } public final byte a() { long j = this.b; if (j != 0) { b1 b1Var = this.a; int i = b1Var.b; int i2 = b1Var.c; int i3 = i + 1; byte b = b1Var.a[i]; this.b = j - 1; if (i3 == i2) { this.a = b1Var.a(); c1.a(b1Var); } else { b1Var.b = i3; } return b; } throw new IllegalStateException("size == 0"); } public final int b() { long j = this.b; if (j >= 4) { b1 b1Var = this.a; int i = b1Var.b; int i2 = b1Var.c; if (i2 - i < 4) { return ((a() & 255) << 24) | ((a() & 255) << 16) | ((a() & 255) << 8) | (a() & 255); } byte[] bArr = b1Var.a; int i3 = i + 3; int i4 = ((bArr[i + 1] & 255) << 16) | ((bArr[i] & 255) << 24) | ((bArr[i + 2] & 255) << 8); int i5 = i + 4; int i6 = (bArr[i3] & 255) | i4; this.b = j - 4; if (i5 == i2) { this.a = b1Var.a(); c1.a(b1Var); } else { b1Var.b = i5; } return i6; } throw new IllegalStateException("size < 4: " + this.b); } public final int hashCode() { b1 b1Var = this.a; if (b1Var == null) { return 0; } int i = 1; do { int i2 = b1Var.c; for (int i3 = b1Var.b; i3 < i2; i3++) { i = (i * 31) + b1Var.a[i3]; } b1Var = b1Var.f; } while (b1Var != this.a); return i; } public final byte[] a(long j) { int min; f3.a(this.b, 0L, j); if (j <= 2147483647L) { int i = (int) j; byte[] bArr = new byte[i]; int i2 = 0; while (i2 < i) { int i3 = i - i2; f3.a(i, i2, i3); b1 b1Var = this.a; if (b1Var == null) { min = -1; } else { min = Math.min(i3, b1Var.c - b1Var.b); System.arraycopy(b1Var.a, b1Var.b, bArr, i2, min); int i4 = b1Var.b + min; b1Var.b = i4; this.b -= min; if (i4 == b1Var.c) { this.a = b1Var.a(); c1.a(b1Var); } } if (min == -1) { throw new EOFException(); } i2 += min; } return bArr; } throw new IllegalArgumentException("byteCount > Integer.MAX_VALUE: " + j); } public final String b(long j) { Charset charset = f3.a; f3.a(this.b, 0L, j); if (charset == null) { throw new IllegalArgumentException("charset == null"); } if (j > 2147483647L) { throw new IllegalArgumentException("byteCount > Integer.MAX_VALUE: " + j); } if (j == 0) { return ""; } b1 b1Var = this.a; int i = b1Var.b; if (i + j > b1Var.c) { return new String(a(j), charset); } String str = new String(b1Var.a, i, (int) j, charset); int i2 = (int) (b1Var.b + j); b1Var.b = i2; this.b -= j; if (i2 == b1Var.c) { this.a = b1Var.a(); c1.a(b1Var); } return str; } public final l a(byte[] bArr, int i) { if (bArr != null) { int i2 = 0; long j = i; f3.a(bArr.length, 0, j); while (i2 < i) { b1 a = a(1); int min = Math.min(i - i2, 8192 - a.c); System.arraycopy(bArr, i2, a.a, a.c, min); i2 += min; a.c += min; } this.b += j; return this; } throw new IllegalArgumentException("source == null"); } public final l b(int i) { b1 a = a(1); byte[] bArr = a.a; int i2 = a.c; a.c = i2 + 1; bArr[i2] = (byte) i; this.b++; return this; } public final b1 a(int i) { if (i < 1 || i > 8192) { throw new IllegalArgumentException(); } b1 b1Var = this.a; if (b1Var == null) { b1 a = c1.a(); this.a = a; a.g = a; a.f = a; return a; } b1 b1Var2 = b1Var.g; if (b1Var2.c + i <= 8192 && b1Var2.e) { return b1Var2; } b1 a2 = c1.a(); a2.g = b1Var2; a2.f = b1Var2.f; b1Var2.f.g = a2; b1Var2.f = a2; return a2; } }