Initial commit
This commit is contained in:
6
sources/com/squareup/haha/guava/base/Function.java
Normal file
6
sources/com/squareup/haha/guava/base/Function.java
Normal file
@@ -0,0 +1,6 @@
|
||||
package com.squareup.haha.guava.base;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface Function<F, T> {
|
||||
T apply(F f);
|
||||
}
|
211
sources/com/squareup/haha/guava/base/Joiner.java
Normal file
211
sources/com/squareup/haha/guava/base/Joiner.java
Normal file
@@ -0,0 +1,211 @@
|
||||
package com.squareup.haha.guava.base;
|
||||
|
||||
import com.squareup.haha.guava.collect.ImmutableList;
|
||||
import com.squareup.haha.guava.collect.Iterators;
|
||||
import com.squareup.haha.guava.collect.Lists$RandomAccessReverseList;
|
||||
import com.squareup.haha.guava.collect.Lists$ReverseList;
|
||||
import com.squareup.haha.guava.collect.Multiset;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.RandomAccess;
|
||||
import java.util.Set;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Joiner {
|
||||
private final String separator;
|
||||
|
||||
public static final class MapJoiner {
|
||||
public /* synthetic */ MapJoiner(Joiner joiner, String str, byte b) {
|
||||
this(joiner, str);
|
||||
}
|
||||
|
||||
private MapJoiner(Joiner joiner, String str) {
|
||||
Joiner.checkNotNull(str);
|
||||
}
|
||||
}
|
||||
|
||||
/* synthetic */ Joiner(Joiner joiner, byte b) {
|
||||
this(joiner);
|
||||
}
|
||||
|
||||
static String badPositionIndex(int i, int i2, String str) {
|
||||
if (i < 0) {
|
||||
return format("%s (%s) must not be negative", str, Integer.valueOf(i));
|
||||
}
|
||||
if (i2 >= 0) {
|
||||
return format("%s (%s) must not be greater than size (%s)", str, Integer.valueOf(i), Integer.valueOf(i2));
|
||||
}
|
||||
throw new IllegalArgumentException("negative size: " + i2);
|
||||
}
|
||||
|
||||
public static void checkArgument(boolean z) {
|
||||
if (!z) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
public static int checkElementIndex(int i, int i2) {
|
||||
String format;
|
||||
if (i >= 0 && i < i2) {
|
||||
return i;
|
||||
}
|
||||
if (i < 0) {
|
||||
format = format("%s (%s) must not be negative", "index", Integer.valueOf(i));
|
||||
} else {
|
||||
if (i2 < 0) {
|
||||
throw new IllegalArgumentException("negative size: " + i2);
|
||||
}
|
||||
format = format("%s (%s) must be less than size (%s)", "index", Integer.valueOf(i), Integer.valueOf(i2));
|
||||
}
|
||||
throw new IndexOutOfBoundsException(format);
|
||||
}
|
||||
|
||||
public static <T> T checkNotNull(T t) {
|
||||
if (t != null) {
|
||||
return t;
|
||||
}
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
public static int checkPositionIndex(int i, int i2) {
|
||||
if (i < 0 || i > i2) {
|
||||
throw new IndexOutOfBoundsException(badPositionIndex(i, i2, "index"));
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public static void checkPositionIndexes(int i, int i2, int i3) {
|
||||
if (i < 0 || i2 < i || i2 > i3) {
|
||||
throw new IndexOutOfBoundsException((i < 0 || i > i3) ? badPositionIndex(i, i3, "start index") : (i2 < 0 || i2 > i3) ? badPositionIndex(i2, i3, "end index") : format("end index (%s) must not be less than start index (%s)", Integer.valueOf(i2), Integer.valueOf(i)));
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkRemove(boolean z) {
|
||||
if (!z) {
|
||||
throw new IllegalStateException("no calls to next() since the last call to remove()");
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean equal(Object obj, Object obj2) {
|
||||
if (obj != obj2) {
|
||||
return obj != null && obj.equals(obj2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean equalsImpl(Set<?> set, Object obj) {
|
||||
if (set == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof Set) {
|
||||
Set set2 = (Set) obj;
|
||||
try {
|
||||
if (set.size() == set2.size()) {
|
||||
if (set.containsAll(set2)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (ClassCastException | NullPointerException unused) {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static String format(String str, Object... objArr) {
|
||||
int indexOf;
|
||||
String valueOf = String.valueOf(str);
|
||||
StringBuilder sb = new StringBuilder(valueOf.length() + (objArr.length * 16));
|
||||
int i = 0;
|
||||
int i2 = 0;
|
||||
while (i < objArr.length && (indexOf = valueOf.indexOf("%s", i2)) != -1) {
|
||||
sb.append(valueOf.substring(i2, indexOf));
|
||||
sb.append(objArr[i]);
|
||||
i2 = indexOf + 2;
|
||||
i++;
|
||||
}
|
||||
sb.append(valueOf.substring(i2));
|
||||
if (i < objArr.length) {
|
||||
sb.append(" [");
|
||||
sb.append(objArr[i]);
|
||||
for (int i3 = i + 1; i3 < objArr.length; i3++) {
|
||||
sb.append(", ");
|
||||
sb.append(objArr[i3]);
|
||||
}
|
||||
sb.append(']');
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static boolean removeAllImpl(Set<?> set, Iterator<?> it) {
|
||||
boolean z = false;
|
||||
while (it.hasNext()) {
|
||||
z |= set.remove(it.next());
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
public static <T> List<T> reverse(List<T> list) {
|
||||
return list instanceof ImmutableList ? ((ImmutableList) list).reverse() : list instanceof Lists$ReverseList ? ((Lists$ReverseList) list).forwardList : list instanceof RandomAccess ? new Lists$RandomAccessReverseList(list) : new Lists$ReverseList(list);
|
||||
}
|
||||
|
||||
public final StringBuilder appendTo(StringBuilder sb, Iterator<?> it) {
|
||||
try {
|
||||
checkNotNull(sb);
|
||||
if (it.hasNext()) {
|
||||
sb.append(toString(it.next()));
|
||||
while (it.hasNext()) {
|
||||
sb.append((CharSequence) this.separator);
|
||||
sb.append(toString(it.next()));
|
||||
}
|
||||
}
|
||||
return sb;
|
||||
} catch (IOException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
CharSequence toString(Object obj) {
|
||||
checkNotNull(obj);
|
||||
return obj instanceof CharSequence ? (CharSequence) obj : obj.toString();
|
||||
}
|
||||
|
||||
public Joiner useForNull(final String str) {
|
||||
checkNotNull(str);
|
||||
return new Joiner(this) { // from class: com.squareup.haha.guava.base.Joiner.1
|
||||
{
|
||||
byte b = 0;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.base.Joiner
|
||||
final CharSequence toString(Object obj) {
|
||||
return obj == null ? str : Joiner.this.toString(obj);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.base.Joiner
|
||||
public final Joiner useForNull(String str2) {
|
||||
throw new UnsupportedOperationException("already specified useForNull");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public Joiner(String str) {
|
||||
this.separator = (String) checkNotNull(str);
|
||||
}
|
||||
|
||||
public static boolean removeAllImpl(Set<?> set, Collection<?> collection) {
|
||||
checkNotNull(collection);
|
||||
if (collection instanceof Multiset) {
|
||||
collection = ((Multiset) collection).elementSet();
|
||||
}
|
||||
if ((collection instanceof Set) && collection.size() > set.size()) {
|
||||
return Iterators.removeAll(set.iterator(), collection);
|
||||
}
|
||||
return removeAllImpl(set, collection.iterator());
|
||||
}
|
||||
|
||||
private Joiner(Joiner joiner) {
|
||||
this.separator = joiner.separator;
|
||||
}
|
||||
}
|
6
sources/com/squareup/haha/guava/base/Predicate.java
Normal file
6
sources/com/squareup/haha/guava/base/Predicate.java
Normal file
@@ -0,0 +1,6 @@
|
||||
package com.squareup.haha.guava.base;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface Predicate<T> {
|
||||
boolean apply(T t);
|
||||
}
|
52
sources/com/squareup/haha/guava/base/Predicates.java
Normal file
52
sources/com/squareup/haha/guava/base/Predicates.java
Normal file
@@ -0,0 +1,52 @@
|
||||
package com.squareup.haha.guava.base;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class Predicates {
|
||||
|
||||
static class InPredicate<T> implements Predicate<T>, Serializable {
|
||||
private final Collection<?> target;
|
||||
|
||||
/* synthetic */ InPredicate(Collection collection, byte b) {
|
||||
this(collection);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.base.Predicate
|
||||
public final boolean apply(T t) {
|
||||
try {
|
||||
return this.target.contains(t);
|
||||
} catch (ClassCastException | NullPointerException unused) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean equals(Object obj) {
|
||||
if (obj instanceof InPredicate) {
|
||||
return this.target.equals(((InPredicate) obj).target);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public final int hashCode() {
|
||||
return this.target.hashCode();
|
||||
}
|
||||
|
||||
public final String toString() {
|
||||
return "Predicates.in(" + this.target + ")";
|
||||
}
|
||||
|
||||
private InPredicate(Collection<?> collection) {
|
||||
this.target = (Collection) Joiner.checkNotNull(collection);
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
new Joiner(",");
|
||||
}
|
||||
|
||||
public static <T> Predicate<T> in(Collection<? extends T> collection) {
|
||||
return new InPredicate(collection, (byte) 0);
|
||||
}
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
package com.squareup.haha.guava.collect;
|
||||
|
||||
import com.squareup.haha.guava.base.Joiner;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
abstract class AbstractIndexedListIterator<E> extends UnmodifiableListIterator<E> {
|
||||
private int position;
|
||||
private final int size;
|
||||
|
||||
protected AbstractIndexedListIterator(int i, int i2) {
|
||||
Joiner.checkPositionIndex(i2, i);
|
||||
this.size = i;
|
||||
this.position = i2;
|
||||
}
|
||||
|
||||
protected abstract E get(int i);
|
||||
|
||||
@Override // java.util.Iterator, java.util.ListIterator
|
||||
public final boolean hasNext() {
|
||||
return this.position < this.size;
|
||||
}
|
||||
|
||||
@Override // java.util.ListIterator
|
||||
public final boolean hasPrevious() {
|
||||
return this.position > 0;
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator, java.util.ListIterator
|
||||
public final E next() {
|
||||
if (!hasNext()) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
int i = this.position;
|
||||
this.position = i + 1;
|
||||
return get(i);
|
||||
}
|
||||
|
||||
@Override // java.util.ListIterator
|
||||
public final int nextIndex() {
|
||||
return this.position;
|
||||
}
|
||||
|
||||
@Override // java.util.ListIterator
|
||||
public final E previous() {
|
||||
if (!hasPrevious()) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
int i = this.position - 1;
|
||||
this.position = i;
|
||||
return get(i);
|
||||
}
|
||||
|
||||
@Override // java.util.ListIterator
|
||||
public final int previousIndex() {
|
||||
return this.position - 1;
|
||||
}
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
package com.squareup.haha.guava.collect;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
abstract class AbstractListMultimap<K, V> extends AbstractMapBasedMultimap<K, V> implements ListMultimap<K, V> {
|
||||
protected AbstractListMultimap(Map<K, Collection<V>> map) {
|
||||
super(map);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.AbstractMultimap, com.squareup.haha.guava.collect.Multimap
|
||||
public Map<K, Collection<V>> asMap() {
|
||||
return super.asMap();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: package-private */
|
||||
@Override // com.squareup.haha.guava.collect.AbstractMapBasedMultimap
|
||||
public abstract List<V> createCollection();
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.AbstractMultimap
|
||||
public boolean equals(Object obj) {
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
@Override // com.squareup.haha.guava.collect.AbstractMapBasedMultimap, com.squareup.haha.guava.collect.Multimap
|
||||
public final /* bridge */ /* synthetic */ Collection get(Object obj) {
|
||||
return get((AbstractListMultimap<K, V>) obj);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.AbstractMapBasedMultimap, com.squareup.haha.guava.collect.AbstractMultimap, com.squareup.haha.guava.collect.Multimap
|
||||
public boolean put(K k, V v) {
|
||||
return super.put(k, v);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.AbstractMapBasedMultimap, com.squareup.haha.guava.collect.Multimap
|
||||
public List<V> get(K k) {
|
||||
return (List) super.get((AbstractListMultimap<K, V>) k);
|
||||
}
|
||||
}
|
@@ -0,0 +1,949 @@
|
||||
package com.squareup.haha.guava.collect;
|
||||
|
||||
import com.squareup.haha.guava.base.Joiner;
|
||||
import com.squareup.haha.guava.collect.Maps;
|
||||
import java.io.Serializable;
|
||||
import java.util.AbstractCollection;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
import java.util.RandomAccess;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
import java.util.SortedSet;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
abstract class AbstractMapBasedMultimap<K, V> extends AbstractMultimap<K, V> implements Serializable {
|
||||
private transient Map<K, Collection<V>> map;
|
||||
private transient int totalSize;
|
||||
|
||||
class AsMap extends Maps.ImprovedAbstractMap<K, Collection<V>> {
|
||||
final transient Map<K, Collection<V>> submap;
|
||||
|
||||
class AsMapEntries extends Maps.EntrySet<K, Collection<V>> {
|
||||
AsMapEntries() {
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.Maps.EntrySet, java.util.AbstractCollection, java.util.Collection, java.util.Set
|
||||
public final boolean contains(Object obj) {
|
||||
return Collections2.safeContains(AsMap.this.submap.entrySet(), obj);
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
|
||||
public final Iterator<Map.Entry<K, Collection<V>>> iterator() {
|
||||
return AsMap.this.new AsMapIterator();
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.Maps.EntrySet
|
||||
final Map<K, Collection<V>> map() {
|
||||
return AsMap.this;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.Maps.EntrySet, java.util.AbstractCollection, java.util.Collection, java.util.Set
|
||||
public final boolean remove(Object obj) {
|
||||
if (!contains(obj)) {
|
||||
return false;
|
||||
}
|
||||
AbstractMapBasedMultimap.access$400(AbstractMapBasedMultimap.this, ((Map.Entry) obj).getKey());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class AsMapIterator implements Iterator<Map.Entry<K, Collection<V>>> {
|
||||
private Collection<V> collection;
|
||||
private Iterator<Map.Entry<K, Collection<V>>> delegateIterator;
|
||||
|
||||
AsMapIterator() {
|
||||
this.delegateIterator = AsMap.this.submap.entrySet().iterator();
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public final boolean hasNext() {
|
||||
return this.delegateIterator.hasNext();
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public final /* bridge */ /* synthetic */ Object next() {
|
||||
Map.Entry<K, Collection<V>> next = this.delegateIterator.next();
|
||||
this.collection = next.getValue();
|
||||
AsMap asMap = AsMap.this;
|
||||
K key = next.getKey();
|
||||
return Maps.immutableEntry(key, AbstractMapBasedMultimap.this.wrapCollection(key, next.getValue()));
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public final void remove() {
|
||||
this.delegateIterator.remove();
|
||||
AbstractMapBasedMultimap.access$220(AbstractMapBasedMultimap.this, this.collection.size());
|
||||
this.collection.clear();
|
||||
}
|
||||
}
|
||||
|
||||
AsMap(Map<K, Collection<V>> map) {
|
||||
this.submap = map;
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractMap, java.util.Map
|
||||
public void clear() {
|
||||
if (this.submap == AbstractMapBasedMultimap.this.map) {
|
||||
AbstractMapBasedMultimap.this.clear();
|
||||
} else {
|
||||
Iterators.clear(new AsMapIterator());
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractMap, java.util.Map
|
||||
public boolean containsKey(Object obj) {
|
||||
return Maps.safeContainsKey(this.submap, obj);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.Maps.ImprovedAbstractMap
|
||||
protected final Set<Map.Entry<K, Collection<V>>> createEntrySet() {
|
||||
return new AsMapEntries();
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractMap, java.util.Map
|
||||
public boolean equals(Object obj) {
|
||||
return this == obj || this.submap.equals(obj);
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractMap, java.util.Map
|
||||
public /* bridge */ /* synthetic */ Object get(Object obj) {
|
||||
Collection<V> collection = (Collection) Maps.safeGet(this.submap, obj);
|
||||
if (collection == null) {
|
||||
return null;
|
||||
}
|
||||
return AbstractMapBasedMultimap.this.wrapCollection(obj, collection);
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractMap, java.util.Map
|
||||
public int hashCode() {
|
||||
return this.submap.hashCode();
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.Maps.ImprovedAbstractMap, java.util.AbstractMap, java.util.Map
|
||||
public Set<K> keySet() {
|
||||
return AbstractMapBasedMultimap.this.keySet();
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractMap, java.util.Map
|
||||
public /* bridge */ /* synthetic */ Object remove(Object obj) {
|
||||
Collection<V> remove = this.submap.remove(obj);
|
||||
if (remove == null) {
|
||||
return null;
|
||||
}
|
||||
Collection<V> createCollection = AbstractMapBasedMultimap.this.createCollection();
|
||||
createCollection.addAll(remove);
|
||||
AbstractMapBasedMultimap.access$220(AbstractMapBasedMultimap.this, remove.size());
|
||||
remove.clear();
|
||||
return createCollection;
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractMap, java.util.Map
|
||||
public int size() {
|
||||
return this.submap.size();
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractMap
|
||||
public String toString() {
|
||||
return this.submap.toString();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class Itr<T> implements Iterator<T> {
|
||||
private Iterator<Map.Entry<K, Collection<V>>> keyIterator;
|
||||
private K key = null;
|
||||
private Collection<V> collection = null;
|
||||
private Iterator<V> valueIterator = Iterators.emptyModifiableIterator();
|
||||
|
||||
Itr() {
|
||||
this.keyIterator = AbstractMapBasedMultimap.this.map.entrySet().iterator();
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public boolean hasNext() {
|
||||
return this.keyIterator.hasNext() || this.valueIterator.hasNext();
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public T next() {
|
||||
if (!this.valueIterator.hasNext()) {
|
||||
Map.Entry<K, Collection<V>> next = this.keyIterator.next();
|
||||
this.key = next.getKey();
|
||||
this.collection = next.getValue();
|
||||
this.valueIterator = this.collection.iterator();
|
||||
}
|
||||
return output(this.key, this.valueIterator.next());
|
||||
}
|
||||
|
||||
abstract T output(K k, V v);
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public void remove() {
|
||||
this.valueIterator.remove();
|
||||
if (this.collection.isEmpty()) {
|
||||
this.keyIterator.remove();
|
||||
}
|
||||
AbstractMapBasedMultimap.access$210(AbstractMapBasedMultimap.this);
|
||||
}
|
||||
}
|
||||
|
||||
class KeySet extends Maps.KeySet<K, Collection<V>> {
|
||||
KeySet(Map<K, Collection<V>> map) {
|
||||
super(map);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.Maps.KeySet, java.util.AbstractCollection, java.util.Collection, java.util.Set
|
||||
public void clear() {
|
||||
Iterators.clear(iterator());
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
||||
public boolean containsAll(Collection<?> collection) {
|
||||
return this.map.keySet().containsAll(collection);
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractSet, java.util.Collection, java.util.Set
|
||||
public boolean equals(Object obj) {
|
||||
return this == obj || this.map.keySet().equals(obj);
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractSet, java.util.Collection, java.util.Set
|
||||
public int hashCode() {
|
||||
return this.map.keySet().hashCode();
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.Maps.KeySet, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
|
||||
public Iterator<K> iterator() {
|
||||
final Iterator<Map.Entry<K, V>> it = this.map.entrySet().iterator();
|
||||
return new Iterator<K>() { // from class: com.squareup.haha.guava.collect.AbstractMapBasedMultimap.KeySet.1
|
||||
private Map.Entry<K, Collection<V>> entry;
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public final boolean hasNext() {
|
||||
return it.hasNext();
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public final K next() {
|
||||
this.entry = (Map.Entry) it.next();
|
||||
return this.entry.getKey();
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public final void remove() {
|
||||
Joiner.checkRemove(this.entry != null);
|
||||
Collection<V> value = this.entry.getValue();
|
||||
it.remove();
|
||||
AbstractMapBasedMultimap.access$220(AbstractMapBasedMultimap.this, value.size());
|
||||
value.clear();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.Maps.KeySet, java.util.AbstractCollection, java.util.Collection, java.util.Set
|
||||
public boolean remove(Object obj) {
|
||||
int i;
|
||||
Collection collection = (Collection) this.map.remove(obj);
|
||||
if (collection != null) {
|
||||
i = collection.size();
|
||||
collection.clear();
|
||||
AbstractMapBasedMultimap.access$220(AbstractMapBasedMultimap.this, i);
|
||||
} else {
|
||||
i = 0;
|
||||
}
|
||||
return i > 0;
|
||||
}
|
||||
}
|
||||
|
||||
class RandomAccessWrappedList extends WrappedList implements RandomAccess {
|
||||
RandomAccessWrappedList(AbstractMapBasedMultimap abstractMapBasedMultimap, Object obj, List list, WrappedCollection wrappedCollection) {
|
||||
super(obj, list, wrappedCollection);
|
||||
}
|
||||
}
|
||||
|
||||
class SortedAsMap extends AsMap implements SortedMap {
|
||||
private SortedSet<K> sortedKeySet;
|
||||
|
||||
SortedAsMap(SortedMap<K, Collection<V>> sortedMap) {
|
||||
super(sortedMap);
|
||||
}
|
||||
|
||||
@Override // java.util.SortedMap
|
||||
public final Comparator<? super K> comparator() {
|
||||
return ((SortedMap) this.submap).comparator();
|
||||
}
|
||||
|
||||
@Override // java.util.SortedMap
|
||||
public final K firstKey() {
|
||||
return (K) ((SortedMap) this.submap).firstKey();
|
||||
}
|
||||
|
||||
@Override // java.util.SortedMap
|
||||
public final SortedMap<K, Collection<V>> headMap(K k) {
|
||||
return new SortedAsMap(((SortedMap) this.submap).headMap(k));
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.AbstractMapBasedMultimap.AsMap, com.squareup.haha.guava.collect.Maps.ImprovedAbstractMap, java.util.AbstractMap, java.util.Map
|
||||
public final /* bridge */ /* synthetic */ Set keySet() {
|
||||
SortedSet<K> sortedSet = this.sortedKeySet;
|
||||
if (sortedSet != null) {
|
||||
return sortedSet;
|
||||
}
|
||||
SortedSet<K> mo16createKeySet = mo16createKeySet();
|
||||
this.sortedKeySet = mo16createKeySet;
|
||||
return mo16createKeySet;
|
||||
}
|
||||
|
||||
@Override // java.util.SortedMap
|
||||
public final K lastKey() {
|
||||
return (K) ((SortedMap) this.submap).lastKey();
|
||||
}
|
||||
|
||||
@Override // java.util.SortedMap
|
||||
public final SortedMap<K, Collection<V>> subMap(K k, K k2) {
|
||||
return new SortedAsMap(((SortedMap) this.submap).subMap(k, k2));
|
||||
}
|
||||
|
||||
@Override // java.util.SortedMap
|
||||
public final SortedMap<K, Collection<V>> tailMap(K k) {
|
||||
return new SortedAsMap(((SortedMap) this.submap).tailMap(k));
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
@Override // com.squareup.haha.guava.collect.Maps.ImprovedAbstractMap
|
||||
/* renamed from: createKeySet, reason: merged with bridge method [inline-methods] */
|
||||
public SortedSet<K> mo16createKeySet() {
|
||||
return new SortedKeySet((SortedMap) this.submap);
|
||||
}
|
||||
}
|
||||
|
||||
class SortedKeySet extends KeySet implements SortedSet {
|
||||
SortedKeySet(SortedMap<K, Collection<V>> sortedMap) {
|
||||
super(sortedMap);
|
||||
}
|
||||
|
||||
private SortedMap<K, Collection<V>> sortedMap() {
|
||||
return (SortedMap) this.map;
|
||||
}
|
||||
|
||||
@Override // java.util.SortedSet
|
||||
public final Comparator<? super K> comparator() {
|
||||
return sortedMap().comparator();
|
||||
}
|
||||
|
||||
@Override // java.util.SortedSet
|
||||
public final K first() {
|
||||
return sortedMap().firstKey();
|
||||
}
|
||||
|
||||
@Override // java.util.SortedSet
|
||||
public final SortedSet<K> headSet(K k) {
|
||||
return new SortedKeySet(sortedMap().headMap(k));
|
||||
}
|
||||
|
||||
@Override // java.util.SortedSet
|
||||
public final K last() {
|
||||
return sortedMap().lastKey();
|
||||
}
|
||||
|
||||
@Override // java.util.SortedSet
|
||||
public final SortedSet<K> subSet(K k, K k2) {
|
||||
return new SortedKeySet(sortedMap().subMap(k, k2));
|
||||
}
|
||||
|
||||
@Override // java.util.SortedSet
|
||||
public final SortedSet<K> tailSet(K k) {
|
||||
return new SortedKeySet(sortedMap().tailMap(k));
|
||||
}
|
||||
}
|
||||
|
||||
class WrappedSet extends WrappedCollection implements Set {
|
||||
WrappedSet(K k, Set<V> set) {
|
||||
super(k, set, null);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.AbstractMapBasedMultimap.WrappedCollection, java.util.AbstractCollection, java.util.Collection
|
||||
public final boolean removeAll(Collection<?> collection) {
|
||||
if (collection.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
int size = size();
|
||||
boolean removeAllImpl = Joiner.removeAllImpl((Set<?>) this.delegate, collection);
|
||||
if (removeAllImpl) {
|
||||
AbstractMapBasedMultimap.access$212(AbstractMapBasedMultimap.this, this.delegate.size() - size);
|
||||
removeIfEmpty();
|
||||
}
|
||||
return removeAllImpl;
|
||||
}
|
||||
}
|
||||
|
||||
class WrappedSortedSet extends WrappedCollection implements SortedSet {
|
||||
WrappedSortedSet(Object obj, SortedSet sortedSet, WrappedCollection wrappedCollection) {
|
||||
super(obj, sortedSet, wrappedCollection);
|
||||
}
|
||||
|
||||
private SortedSet<V> getSortedSetDelegate() {
|
||||
return (SortedSet) this.delegate;
|
||||
}
|
||||
|
||||
@Override // java.util.SortedSet
|
||||
public final Comparator<? super V> comparator() {
|
||||
return getSortedSetDelegate().comparator();
|
||||
}
|
||||
|
||||
@Override // java.util.SortedSet
|
||||
public final V first() {
|
||||
refreshIfEmpty();
|
||||
return getSortedSetDelegate().first();
|
||||
}
|
||||
|
||||
@Override // java.util.SortedSet
|
||||
public final SortedSet<V> headSet(V v) {
|
||||
refreshIfEmpty();
|
||||
AbstractMapBasedMultimap abstractMapBasedMultimap = AbstractMapBasedMultimap.this;
|
||||
K k = this.key;
|
||||
SortedSet<V> headSet = getSortedSetDelegate().headSet(v);
|
||||
WrappedCollection wrappedCollection = this.ancestor;
|
||||
if (wrappedCollection == null) {
|
||||
wrappedCollection = this;
|
||||
}
|
||||
return new WrappedSortedSet(k, headSet, wrappedCollection);
|
||||
}
|
||||
|
||||
@Override // java.util.SortedSet
|
||||
public final V last() {
|
||||
refreshIfEmpty();
|
||||
return getSortedSetDelegate().last();
|
||||
}
|
||||
|
||||
@Override // java.util.SortedSet
|
||||
public final SortedSet<V> subSet(V v, V v2) {
|
||||
refreshIfEmpty();
|
||||
AbstractMapBasedMultimap abstractMapBasedMultimap = AbstractMapBasedMultimap.this;
|
||||
K k = this.key;
|
||||
SortedSet<V> subSet = getSortedSetDelegate().subSet(v, v2);
|
||||
WrappedCollection wrappedCollection = this.ancestor;
|
||||
if (wrappedCollection == null) {
|
||||
wrappedCollection = this;
|
||||
}
|
||||
return new WrappedSortedSet(k, subSet, wrappedCollection);
|
||||
}
|
||||
|
||||
@Override // java.util.SortedSet
|
||||
public final SortedSet<V> tailSet(V v) {
|
||||
refreshIfEmpty();
|
||||
AbstractMapBasedMultimap abstractMapBasedMultimap = AbstractMapBasedMultimap.this;
|
||||
K k = this.key;
|
||||
SortedSet<V> tailSet = getSortedSetDelegate().tailSet(v);
|
||||
WrappedCollection wrappedCollection = this.ancestor;
|
||||
if (wrappedCollection == null) {
|
||||
wrappedCollection = this;
|
||||
}
|
||||
return new WrappedSortedSet(k, tailSet, wrappedCollection);
|
||||
}
|
||||
}
|
||||
|
||||
protected AbstractMapBasedMultimap(Map<K, Collection<V>> map) {
|
||||
Joiner.checkArgument(map.isEmpty());
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
static /* synthetic */ Iterator access$100(AbstractMapBasedMultimap abstractMapBasedMultimap, Collection collection) {
|
||||
return collection instanceof List ? ((List) collection).listIterator() : collection.iterator();
|
||||
}
|
||||
|
||||
static /* synthetic */ int access$208(AbstractMapBasedMultimap abstractMapBasedMultimap) {
|
||||
int i = abstractMapBasedMultimap.totalSize;
|
||||
abstractMapBasedMultimap.totalSize = i + 1;
|
||||
return i;
|
||||
}
|
||||
|
||||
static /* synthetic */ int access$210(AbstractMapBasedMultimap abstractMapBasedMultimap) {
|
||||
int i = abstractMapBasedMultimap.totalSize;
|
||||
abstractMapBasedMultimap.totalSize = i - 1;
|
||||
return i;
|
||||
}
|
||||
|
||||
static /* synthetic */ int access$212(AbstractMapBasedMultimap abstractMapBasedMultimap, int i) {
|
||||
int i2 = abstractMapBasedMultimap.totalSize + i;
|
||||
abstractMapBasedMultimap.totalSize = i2;
|
||||
return i2;
|
||||
}
|
||||
|
||||
static /* synthetic */ int access$220(AbstractMapBasedMultimap abstractMapBasedMultimap, int i) {
|
||||
int i2 = abstractMapBasedMultimap.totalSize - i;
|
||||
abstractMapBasedMultimap.totalSize = i2;
|
||||
return i2;
|
||||
}
|
||||
|
||||
static /* synthetic */ int access$400(AbstractMapBasedMultimap abstractMapBasedMultimap, Object obj) {
|
||||
Collection collection = (Collection) Maps.safeRemove(abstractMapBasedMultimap.map, obj);
|
||||
if (collection == null) {
|
||||
return 0;
|
||||
}
|
||||
int size = collection.size();
|
||||
collection.clear();
|
||||
abstractMapBasedMultimap.totalSize -= size;
|
||||
return size;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public List wrapList(Object obj, List list, WrappedCollection wrappedCollection) {
|
||||
return list instanceof RandomAccess ? new RandomAccessWrappedList(this, obj, list, wrappedCollection) : new WrappedList(obj, list, wrappedCollection);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.Multimap
|
||||
public void clear() {
|
||||
Iterator<Collection<V>> it = this.map.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().clear();
|
||||
}
|
||||
this.map.clear();
|
||||
this.totalSize = 0;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.AbstractMultimap
|
||||
final Map<K, Collection<V>> createAsMap() {
|
||||
Map<K, Collection<V>> map = this.map;
|
||||
return map instanceof SortedMap ? new SortedAsMap((SortedMap) map) : new AsMap(map);
|
||||
}
|
||||
|
||||
abstract Collection<V> createCollection();
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.AbstractMultimap
|
||||
final Set<K> createKeySet() {
|
||||
Map<K, Collection<V>> map = this.map;
|
||||
return map instanceof SortedMap ? new SortedKeySet((SortedMap) map) : new KeySet(map);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.AbstractMultimap
|
||||
public Collection<Map.Entry<K, V>> entries() {
|
||||
return super.entries();
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.AbstractMultimap
|
||||
final Iterator<Map.Entry<K, V>> entryIterator() {
|
||||
return new Itr(this) { // from class: com.squareup.haha.guava.collect.AbstractMapBasedMultimap.2
|
||||
@Override // com.squareup.haha.guava.collect.AbstractMapBasedMultimap.Itr
|
||||
final /* bridge */ /* synthetic */ Object output(Object obj, Object obj2) {
|
||||
return Maps.immutableEntry(obj, obj2);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.Multimap
|
||||
public Collection<V> get(K k) {
|
||||
Collection<V> collection = this.map.get(k);
|
||||
if (collection == null) {
|
||||
collection = createCollection();
|
||||
}
|
||||
return wrapCollection(k, collection);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.AbstractMultimap, com.squareup.haha.guava.collect.Multimap
|
||||
public boolean put(K k, V v) {
|
||||
Collection<V> collection = this.map.get(k);
|
||||
if (collection != null) {
|
||||
if (!collection.add(v)) {
|
||||
return false;
|
||||
}
|
||||
this.totalSize++;
|
||||
return true;
|
||||
}
|
||||
Collection<V> createCollection = createCollection();
|
||||
if (!createCollection.add(v)) {
|
||||
throw new AssertionError("New Collection violated the Collection spec");
|
||||
}
|
||||
this.totalSize++;
|
||||
this.map.put(k, createCollection);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.Multimap
|
||||
public int size() {
|
||||
return this.totalSize;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.AbstractMultimap
|
||||
final Iterator<V> valueIterator() {
|
||||
return new Itr(this) { // from class: com.squareup.haha.guava.collect.AbstractMapBasedMultimap.1
|
||||
@Override // com.squareup.haha.guava.collect.AbstractMapBasedMultimap.Itr
|
||||
final V output(K k, V v) {
|
||||
return v;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.AbstractMultimap, com.squareup.haha.guava.collect.Multimap
|
||||
public Collection<V> values() {
|
||||
return super.values();
|
||||
}
|
||||
|
||||
final Collection<V> wrapCollection(K k, Collection<V> collection) {
|
||||
return collection instanceof SortedSet ? new WrappedSortedSet(k, (SortedSet) collection, null) : collection instanceof Set ? new WrappedSet(k, (Set) collection) : collection instanceof List ? wrapList(k, (List) collection, null) : new WrappedCollection(k, collection, null);
|
||||
}
|
||||
|
||||
class WrappedCollection extends AbstractCollection<V> {
|
||||
final WrappedCollection ancestor;
|
||||
private Collection<V> ancestorDelegate;
|
||||
Collection<V> delegate;
|
||||
final K key;
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
WrappedCollection(Object obj, Collection collection, WrappedCollection wrappedCollection) {
|
||||
this.key = obj;
|
||||
this.delegate = collection;
|
||||
this.ancestor = wrappedCollection;
|
||||
this.ancestorDelegate = wrappedCollection == null ? null : wrappedCollection.delegate;
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection
|
||||
public boolean add(V v) {
|
||||
refreshIfEmpty();
|
||||
boolean isEmpty = this.delegate.isEmpty();
|
||||
boolean add = this.delegate.add(v);
|
||||
if (add) {
|
||||
AbstractMapBasedMultimap.access$208(AbstractMapBasedMultimap.this);
|
||||
if (isEmpty) {
|
||||
addToMap();
|
||||
}
|
||||
}
|
||||
return add;
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection
|
||||
public boolean addAll(Collection<? extends V> collection) {
|
||||
if (collection.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
int size = size();
|
||||
boolean addAll = this.delegate.addAll(collection);
|
||||
if (addAll) {
|
||||
AbstractMapBasedMultimap.access$212(AbstractMapBasedMultimap.this, this.delegate.size() - size);
|
||||
if (size == 0) {
|
||||
addToMap();
|
||||
}
|
||||
}
|
||||
return addAll;
|
||||
}
|
||||
|
||||
final void addToMap() {
|
||||
WrappedCollection wrappedCollection = this.ancestor;
|
||||
if (wrappedCollection != null) {
|
||||
wrappedCollection.addToMap();
|
||||
} else {
|
||||
AbstractMapBasedMultimap.this.map.put(this.key, this.delegate);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection
|
||||
public void clear() {
|
||||
int size = size();
|
||||
if (size == 0) {
|
||||
return;
|
||||
}
|
||||
this.delegate.clear();
|
||||
AbstractMapBasedMultimap.access$220(AbstractMapBasedMultimap.this, size);
|
||||
removeIfEmpty();
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection
|
||||
public boolean contains(Object obj) {
|
||||
refreshIfEmpty();
|
||||
return this.delegate.contains(obj);
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection
|
||||
public boolean containsAll(Collection<?> collection) {
|
||||
refreshIfEmpty();
|
||||
return this.delegate.containsAll(collection);
|
||||
}
|
||||
|
||||
@Override // java.util.Collection
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
refreshIfEmpty();
|
||||
return this.delegate.equals(obj);
|
||||
}
|
||||
|
||||
@Override // java.util.Collection
|
||||
public int hashCode() {
|
||||
refreshIfEmpty();
|
||||
return this.delegate.hashCode();
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
|
||||
public Iterator<V> iterator() {
|
||||
refreshIfEmpty();
|
||||
return new WrappedIterator();
|
||||
}
|
||||
|
||||
final void refreshIfEmpty() {
|
||||
Collection<V> collection;
|
||||
WrappedCollection wrappedCollection = this.ancestor;
|
||||
if (wrappedCollection != null) {
|
||||
wrappedCollection.refreshIfEmpty();
|
||||
if (this.ancestor.delegate != this.ancestorDelegate) {
|
||||
throw new ConcurrentModificationException();
|
||||
}
|
||||
} else {
|
||||
if (!this.delegate.isEmpty() || (collection = (Collection) AbstractMapBasedMultimap.this.map.get(this.key)) == null) {
|
||||
return;
|
||||
}
|
||||
this.delegate = collection;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection
|
||||
public boolean remove(Object obj) {
|
||||
refreshIfEmpty();
|
||||
boolean remove = this.delegate.remove(obj);
|
||||
if (remove) {
|
||||
AbstractMapBasedMultimap.access$210(AbstractMapBasedMultimap.this);
|
||||
removeIfEmpty();
|
||||
}
|
||||
return remove;
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection
|
||||
public boolean removeAll(Collection<?> collection) {
|
||||
if (collection.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
int size = size();
|
||||
boolean removeAll = this.delegate.removeAll(collection);
|
||||
if (removeAll) {
|
||||
AbstractMapBasedMultimap.access$212(AbstractMapBasedMultimap.this, this.delegate.size() - size);
|
||||
removeIfEmpty();
|
||||
}
|
||||
return removeAll;
|
||||
}
|
||||
|
||||
final void removeIfEmpty() {
|
||||
WrappedCollection wrappedCollection = this.ancestor;
|
||||
if (wrappedCollection != null) {
|
||||
wrappedCollection.removeIfEmpty();
|
||||
} else if (this.delegate.isEmpty()) {
|
||||
AbstractMapBasedMultimap.this.map.remove(this.key);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection
|
||||
public boolean retainAll(Collection<?> collection) {
|
||||
Joiner.checkNotNull(collection);
|
||||
int size = size();
|
||||
boolean retainAll = this.delegate.retainAll(collection);
|
||||
if (retainAll) {
|
||||
AbstractMapBasedMultimap.access$212(AbstractMapBasedMultimap.this, this.delegate.size() - size);
|
||||
removeIfEmpty();
|
||||
}
|
||||
return retainAll;
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection
|
||||
public int size() {
|
||||
refreshIfEmpty();
|
||||
return this.delegate.size();
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection
|
||||
public String toString() {
|
||||
refreshIfEmpty();
|
||||
return this.delegate.toString();
|
||||
}
|
||||
|
||||
class WrappedIterator implements Iterator<V> {
|
||||
final Iterator<V> delegateIterator;
|
||||
private Collection<V> originalDelegate;
|
||||
|
||||
WrappedIterator() {
|
||||
this.originalDelegate = WrappedCollection.this.delegate;
|
||||
this.delegateIterator = AbstractMapBasedMultimap.access$100(AbstractMapBasedMultimap.this, WrappedCollection.this.delegate);
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public boolean hasNext() {
|
||||
validateIterator();
|
||||
return this.delegateIterator.hasNext();
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public V next() {
|
||||
validateIterator();
|
||||
return this.delegateIterator.next();
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public void remove() {
|
||||
this.delegateIterator.remove();
|
||||
AbstractMapBasedMultimap.access$210(AbstractMapBasedMultimap.this);
|
||||
WrappedCollection.this.removeIfEmpty();
|
||||
}
|
||||
|
||||
final void validateIterator() {
|
||||
WrappedCollection.this.refreshIfEmpty();
|
||||
if (WrappedCollection.this.delegate != this.originalDelegate) {
|
||||
throw new ConcurrentModificationException();
|
||||
}
|
||||
}
|
||||
|
||||
WrappedIterator(Iterator<V> it) {
|
||||
this.originalDelegate = WrappedCollection.this.delegate;
|
||||
this.delegateIterator = it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class WrappedList extends WrappedCollection implements List {
|
||||
|
||||
class WrappedListIterator extends WrappedCollection.WrappedIterator implements ListIterator {
|
||||
WrappedListIterator() {
|
||||
super();
|
||||
}
|
||||
|
||||
private ListIterator<V> getDelegateListIterator() {
|
||||
validateIterator();
|
||||
return (ListIterator) this.delegateIterator;
|
||||
}
|
||||
|
||||
@Override // java.util.ListIterator
|
||||
public final void add(V v) {
|
||||
boolean isEmpty = WrappedList.this.isEmpty();
|
||||
getDelegateListIterator().add(v);
|
||||
AbstractMapBasedMultimap.access$208(AbstractMapBasedMultimap.this);
|
||||
if (isEmpty) {
|
||||
WrappedList.this.addToMap();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.util.ListIterator
|
||||
public final boolean hasPrevious() {
|
||||
return getDelegateListIterator().hasPrevious();
|
||||
}
|
||||
|
||||
@Override // java.util.ListIterator
|
||||
public final int nextIndex() {
|
||||
return getDelegateListIterator().nextIndex();
|
||||
}
|
||||
|
||||
@Override // java.util.ListIterator
|
||||
public final V previous() {
|
||||
return getDelegateListIterator().previous();
|
||||
}
|
||||
|
||||
@Override // java.util.ListIterator
|
||||
public final int previousIndex() {
|
||||
return getDelegateListIterator().previousIndex();
|
||||
}
|
||||
|
||||
@Override // java.util.ListIterator
|
||||
public final void set(V v) {
|
||||
getDelegateListIterator().set(v);
|
||||
}
|
||||
|
||||
public WrappedListIterator(int i) {
|
||||
super(WrappedList.this.getListDelegate().listIterator(i));
|
||||
}
|
||||
}
|
||||
|
||||
WrappedList(Object obj, List list, WrappedCollection wrappedCollection) {
|
||||
super(obj, list, wrappedCollection);
|
||||
}
|
||||
|
||||
@Override // java.util.List
|
||||
public void add(int i, V v) {
|
||||
refreshIfEmpty();
|
||||
boolean isEmpty = this.delegate.isEmpty();
|
||||
getListDelegate().add(i, v);
|
||||
AbstractMapBasedMultimap.access$208(AbstractMapBasedMultimap.this);
|
||||
if (isEmpty) {
|
||||
addToMap();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.util.List
|
||||
public boolean addAll(int i, Collection<? extends V> collection) {
|
||||
if (collection.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
int size = size();
|
||||
boolean addAll = getListDelegate().addAll(i, collection);
|
||||
if (addAll) {
|
||||
AbstractMapBasedMultimap.access$212(AbstractMapBasedMultimap.this, this.delegate.size() - size);
|
||||
if (size == 0) {
|
||||
addToMap();
|
||||
}
|
||||
}
|
||||
return addAll;
|
||||
}
|
||||
|
||||
@Override // java.util.List
|
||||
public V get(int i) {
|
||||
refreshIfEmpty();
|
||||
return getListDelegate().get(i);
|
||||
}
|
||||
|
||||
final List<V> getListDelegate() {
|
||||
return (List) this.delegate;
|
||||
}
|
||||
|
||||
@Override // java.util.List
|
||||
public int indexOf(Object obj) {
|
||||
refreshIfEmpty();
|
||||
return getListDelegate().indexOf(obj);
|
||||
}
|
||||
|
||||
@Override // java.util.List
|
||||
public int lastIndexOf(Object obj) {
|
||||
refreshIfEmpty();
|
||||
return getListDelegate().lastIndexOf(obj);
|
||||
}
|
||||
|
||||
@Override // java.util.List
|
||||
public ListIterator<V> listIterator() {
|
||||
refreshIfEmpty();
|
||||
return new WrappedListIterator();
|
||||
}
|
||||
|
||||
@Override // java.util.List
|
||||
public V remove(int i) {
|
||||
refreshIfEmpty();
|
||||
V remove = getListDelegate().remove(i);
|
||||
AbstractMapBasedMultimap.access$210(AbstractMapBasedMultimap.this);
|
||||
removeIfEmpty();
|
||||
return remove;
|
||||
}
|
||||
|
||||
@Override // java.util.List
|
||||
public V set(int i, V v) {
|
||||
refreshIfEmpty();
|
||||
return getListDelegate().set(i, v);
|
||||
}
|
||||
|
||||
@Override // java.util.List
|
||||
public List<V> subList(int i, int i2) {
|
||||
refreshIfEmpty();
|
||||
AbstractMapBasedMultimap abstractMapBasedMultimap = AbstractMapBasedMultimap.this;
|
||||
K k = this.key;
|
||||
List<V> subList = getListDelegate().subList(i, i2);
|
||||
WrappedCollection wrappedCollection = this.ancestor;
|
||||
if (wrappedCollection == null) {
|
||||
wrappedCollection = this;
|
||||
}
|
||||
return abstractMapBasedMultimap.wrapList(k, subList, wrappedCollection);
|
||||
}
|
||||
|
||||
@Override // java.util.List
|
||||
public ListIterator<V> listIterator(int i) {
|
||||
refreshIfEmpty();
|
||||
return new WrappedListIterator(i);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
package com.squareup.haha.guava.collect;
|
||||
|
||||
import com.squareup.haha.guava.base.Joiner;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
abstract class AbstractMapEntry<K, V> implements Map.Entry<K, V> {
|
||||
AbstractMapEntry() {
|
||||
}
|
||||
|
||||
@Override // java.util.Map.Entry
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof Map.Entry) {
|
||||
Map.Entry entry = (Map.Entry) obj;
|
||||
if (Joiner.equal(getKey(), entry.getKey()) && Joiner.equal(getValue(), entry.getValue())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // java.util.Map.Entry
|
||||
public abstract K getKey();
|
||||
|
||||
@Override // java.util.Map.Entry
|
||||
public abstract V getValue();
|
||||
|
||||
@Override // java.util.Map.Entry
|
||||
public int hashCode() {
|
||||
K key = getKey();
|
||||
V value = getValue();
|
||||
return (key == null ? 0 : key.hashCode()) ^ (value != null ? value.hashCode() : 0);
|
||||
}
|
||||
|
||||
@Override // java.util.Map.Entry
|
||||
public V setValue(V v) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getKey() + "=" + getValue();
|
||||
}
|
||||
}
|
189
sources/com/squareup/haha/guava/collect/AbstractMultimap.java
Normal file
189
sources/com/squareup/haha/guava/collect/AbstractMultimap.java
Normal file
@@ -0,0 +1,189 @@
|
||||
package com.squareup.haha.guava.collect;
|
||||
|
||||
import com.squareup.haha.guava.base.Joiner;
|
||||
import com.squareup.haha.guava.collect.Maps;
|
||||
import java.util.AbstractCollection;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
abstract class AbstractMultimap<K, V> implements Multimap<K, V> {
|
||||
private transient Map<K, Collection<V>> asMap;
|
||||
private transient Collection<Map.Entry<K, V>> entries;
|
||||
private transient Set<K> keySet;
|
||||
private transient Collection<V> values;
|
||||
|
||||
class Entries extends Multimaps$Entries<K, V> {
|
||||
private Entries() {
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
|
||||
public Iterator<Map.Entry<K, V>> iterator() {
|
||||
return AbstractMultimap.this.entryIterator();
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.Multimaps$Entries
|
||||
final Multimap<K, V> multimap() {
|
||||
return AbstractMultimap.this;
|
||||
}
|
||||
|
||||
/* synthetic */ Entries(AbstractMultimap abstractMultimap, byte b) {
|
||||
this();
|
||||
}
|
||||
}
|
||||
|
||||
class EntrySet extends Entries implements Set {
|
||||
private EntrySet(AbstractMultimap abstractMultimap) {
|
||||
super(abstractMultimap, (byte) 0);
|
||||
}
|
||||
|
||||
@Override // java.util.Collection, java.util.Set
|
||||
public final boolean equals(Object obj) {
|
||||
return Joiner.equalsImpl(this, obj);
|
||||
}
|
||||
|
||||
@Override // java.util.Collection, java.util.Set
|
||||
public final int hashCode() {
|
||||
Iterator it = iterator();
|
||||
int i = 0;
|
||||
while (it.hasNext()) {
|
||||
Object next = it.next();
|
||||
i = ~(~(i + (next != null ? next.hashCode() : 0)));
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/* synthetic */ EntrySet(AbstractMultimap abstractMultimap, byte b) {
|
||||
this(abstractMultimap);
|
||||
}
|
||||
}
|
||||
|
||||
class Values extends AbstractCollection<V> {
|
||||
Values() {
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection
|
||||
public final void clear() {
|
||||
AbstractMultimap.this.clear();
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection
|
||||
public final boolean contains(Object obj) {
|
||||
return AbstractMultimap.this.containsValue(obj);
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
|
||||
public final Iterator<V> iterator() {
|
||||
return AbstractMultimap.this.valueIterator();
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection
|
||||
public final int size() {
|
||||
return AbstractMultimap.this.size();
|
||||
}
|
||||
}
|
||||
|
||||
AbstractMultimap() {
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.Multimap
|
||||
public Map<K, Collection<V>> asMap() {
|
||||
Map<K, Collection<V>> map = this.asMap;
|
||||
if (map != null) {
|
||||
return map;
|
||||
}
|
||||
Map<K, Collection<V>> createAsMap = createAsMap();
|
||||
this.asMap = createAsMap;
|
||||
return createAsMap;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.Multimap
|
||||
public boolean containsEntry(Object obj, Object obj2) {
|
||||
Collection<V> collection = asMap().get(obj);
|
||||
return collection != null && collection.contains(obj2);
|
||||
}
|
||||
|
||||
public boolean containsValue(Object obj) {
|
||||
Iterator<Collection<V>> it = asMap().values().iterator();
|
||||
while (it.hasNext()) {
|
||||
if (it.next().contains(obj)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
abstract Map<K, Collection<V>> createAsMap();
|
||||
|
||||
Set<K> createKeySet() {
|
||||
return new Maps.KeySet(asMap());
|
||||
}
|
||||
|
||||
public Collection<Map.Entry<K, V>> entries() {
|
||||
Collection<Map.Entry<K, V>> collection = this.entries;
|
||||
if (collection == null) {
|
||||
byte b = 0;
|
||||
collection = this instanceof SetMultimap ? new EntrySet(this, b) : new Entries(this, b);
|
||||
this.entries = collection;
|
||||
}
|
||||
return collection;
|
||||
}
|
||||
|
||||
abstract Iterator<Map.Entry<K, V>> entryIterator();
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof Multimap) {
|
||||
return asMap().equals(((Multimap) obj).asMap());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return asMap().hashCode();
|
||||
}
|
||||
|
||||
public Set<K> keySet() {
|
||||
Set<K> set = this.keySet;
|
||||
if (set != null) {
|
||||
return set;
|
||||
}
|
||||
Set<K> createKeySet = createKeySet();
|
||||
this.keySet = createKeySet;
|
||||
return createKeySet;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.Multimap
|
||||
public boolean put(K k, V v) {
|
||||
return get(k).add(v);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.Multimap
|
||||
public boolean remove(Object obj, Object obj2) {
|
||||
Collection<V> collection = asMap().get(obj);
|
||||
return collection != null && collection.remove(obj2);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return asMap().toString();
|
||||
}
|
||||
|
||||
Iterator<V> valueIterator() {
|
||||
return Maps.valueIterator(entries().iterator());
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.Multimap
|
||||
public Collection<V> values() {
|
||||
Collection<V> collection = this.values;
|
||||
if (collection != null) {
|
||||
return collection;
|
||||
}
|
||||
Values values = new Values();
|
||||
this.values = values;
|
||||
return values;
|
||||
}
|
||||
}
|
100
sources/com/squareup/haha/guava/collect/ArrayListMultimap.java
Normal file
100
sources/com/squareup/haha/guava/collect/ArrayListMultimap.java
Normal file
@@ -0,0 +1,100 @@
|
||||
package com.squareup.haha.guava.collect;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class ArrayListMultimap<K, V> extends AbstractListMultimap<K, V> {
|
||||
private transient int expectedValuesPerKey;
|
||||
|
||||
private ArrayListMultimap() {
|
||||
super(new HashMap());
|
||||
this.expectedValuesPerKey = 3;
|
||||
}
|
||||
|
||||
public static <K, V> ArrayListMultimap<K, V> create() {
|
||||
return new ArrayListMultimap<>();
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.AbstractListMultimap, com.squareup.haha.guava.collect.AbstractMultimap, com.squareup.haha.guava.collect.Multimap
|
||||
public final /* bridge */ /* synthetic */ Map asMap() {
|
||||
return super.asMap();
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.AbstractMapBasedMultimap, com.squareup.haha.guava.collect.Multimap
|
||||
public final /* bridge */ /* synthetic */ void clear() {
|
||||
super.clear();
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.AbstractMultimap, com.squareup.haha.guava.collect.Multimap
|
||||
public final /* bridge */ /* synthetic */ boolean containsEntry(Object obj, Object obj2) {
|
||||
return super.containsEntry(obj, obj2);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.AbstractMultimap
|
||||
public final /* bridge */ /* synthetic */ boolean containsValue(Object obj) {
|
||||
return super.containsValue(obj);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.AbstractMapBasedMultimap, com.squareup.haha.guava.collect.AbstractMultimap
|
||||
public final /* bridge */ /* synthetic */ Collection entries() {
|
||||
return super.entries();
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.AbstractListMultimap, com.squareup.haha.guava.collect.AbstractMultimap
|
||||
public final /* bridge */ /* synthetic */ boolean equals(Object obj) {
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
@Override // com.squareup.haha.guava.collect.AbstractListMultimap, com.squareup.haha.guava.collect.AbstractMapBasedMultimap, com.squareup.haha.guava.collect.Multimap
|
||||
public final /* bridge */ /* synthetic */ List get(Object obj) {
|
||||
return super.get((ArrayListMultimap<K, V>) obj);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.AbstractMultimap
|
||||
public final /* bridge */ /* synthetic */ int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.AbstractMultimap
|
||||
public final /* bridge */ /* synthetic */ Set keySet() {
|
||||
return super.keySet();
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
@Override // com.squareup.haha.guava.collect.AbstractListMultimap, com.squareup.haha.guava.collect.AbstractMapBasedMultimap, com.squareup.haha.guava.collect.AbstractMultimap, com.squareup.haha.guava.collect.Multimap
|
||||
public final /* bridge */ /* synthetic */ boolean put(Object obj, Object obj2) {
|
||||
return super.put(obj, obj2);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.AbstractMultimap, com.squareup.haha.guava.collect.Multimap
|
||||
public final /* bridge */ /* synthetic */ boolean remove(Object obj, Object obj2) {
|
||||
return super.remove(obj, obj2);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.AbstractMapBasedMultimap, com.squareup.haha.guava.collect.Multimap
|
||||
public final /* bridge */ /* synthetic */ int size() {
|
||||
return super.size();
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.AbstractMultimap
|
||||
public final /* bridge */ /* synthetic */ String toString() {
|
||||
return super.toString();
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.AbstractMapBasedMultimap, com.squareup.haha.guava.collect.AbstractMultimap, com.squareup.haha.guava.collect.Multimap
|
||||
public final /* bridge */ /* synthetic */ Collection values() {
|
||||
return super.values();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: package-private */
|
||||
@Override // com.squareup.haha.guava.collect.AbstractListMultimap, com.squareup.haha.guava.collect.AbstractMapBasedMultimap
|
||||
public final List<V> createCollection() {
|
||||
return new ArrayList(this.expectedValuesPerKey);
|
||||
}
|
||||
}
|
18
sources/com/squareup/haha/guava/collect/Collections2.java
Normal file
18
sources/com/squareup/haha/guava/collect/Collections2.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.squareup.haha.guava.collect;
|
||||
|
||||
import com.squareup.haha.guava.base.Joiner;
|
||||
import java.util.Collection;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class Collections2 {
|
||||
static final Joiner STANDARD_JOINER = new Joiner(", ").useForNull("null");
|
||||
|
||||
static boolean safeContains(Collection<?> collection, Object obj) {
|
||||
Joiner.checkNotNull(collection);
|
||||
try {
|
||||
return collection.contains(obj);
|
||||
} catch (ClassCastException | NullPointerException unused) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
13
sources/com/squareup/haha/guava/collect/FluentIterable.java
Normal file
13
sources/com/squareup/haha/guava/collect/FluentIterable.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.squareup.haha.guava.collect;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class FluentIterable<E> implements Iterable<E> {
|
||||
private final Iterable<E> iterable = this;
|
||||
|
||||
protected FluentIterable() {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return Iterables.toString(this.iterable);
|
||||
}
|
||||
}
|
29
sources/com/squareup/haha/guava/collect/ImmutableAsList.java
Normal file
29
sources/com/squareup/haha/guava/collect/ImmutableAsList.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package com.squareup.haha.guava.collect;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
abstract class ImmutableAsList<E> extends ImmutableList<E> {
|
||||
ImmutableAsList() {
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableList, com.squareup.haha.guava.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.util.List
|
||||
public boolean contains(Object obj) {
|
||||
return delegateCollection().contains(obj);
|
||||
}
|
||||
|
||||
abstract ImmutableCollection<E> delegateCollection();
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
|
||||
public boolean isEmpty() {
|
||||
return delegateCollection().isEmpty();
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableCollection
|
||||
final boolean isPartialView() {
|
||||
return delegateCollection().isPartialView();
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
|
||||
public int size() {
|
||||
return delegateCollection().size();
|
||||
}
|
||||
}
|
103
sources/com/squareup/haha/guava/collect/ImmutableCollection.java
Normal file
103
sources/com/squareup/haha/guava/collect/ImmutableCollection.java
Normal file
@@ -0,0 +1,103 @@
|
||||
package com.squareup.haha.guava.collect;
|
||||
|
||||
import com.squareup.haha.guava.base.Joiner;
|
||||
import java.io.Serializable;
|
||||
import java.util.AbstractCollection;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class ImmutableCollection<E> extends AbstractCollection<E> implements Serializable {
|
||||
private transient ImmutableList<E> asList;
|
||||
|
||||
ImmutableCollection() {
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection
|
||||
@Deprecated
|
||||
public final boolean add(E e) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection
|
||||
@Deprecated
|
||||
public final boolean addAll(Collection<? extends E> collection) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public ImmutableList<E> asList() {
|
||||
ImmutableList<E> immutableList = this.asList;
|
||||
if (immutableList == null) {
|
||||
int size = size();
|
||||
immutableList = size != 0 ? size != 1 ? new RegularImmutableAsList<>(this, toArray()) : ImmutableList.of((Object) iterator().next()) : ImmutableList.of();
|
||||
this.asList = immutableList;
|
||||
}
|
||||
return immutableList;
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection
|
||||
@Deprecated
|
||||
public final void clear() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
|
||||
public boolean contains(Object obj) {
|
||||
return obj != null && super.contains(obj);
|
||||
}
|
||||
|
||||
int copyIntoArray(Object[] objArr, int i) {
|
||||
Iterator it = iterator();
|
||||
while (it.hasNext()) {
|
||||
objArr[i] = it.next();
|
||||
i++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
abstract boolean isPartialView();
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
|
||||
public abstract UnmodifiableIterator<E> iterator();
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection
|
||||
@Deprecated
|
||||
public final boolean remove(Object obj) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection
|
||||
@Deprecated
|
||||
public final boolean removeAll(Collection<?> collection) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection
|
||||
@Deprecated
|
||||
public final boolean retainAll(Collection<?> collection) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection
|
||||
public final Object[] toArray() {
|
||||
if (size() == 0) {
|
||||
return ObjectArrays.EMPTY_ARRAY;
|
||||
}
|
||||
Object[] objArr = new Object[size()];
|
||||
copyIntoArray(objArr, 0);
|
||||
return objArr;
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection
|
||||
public final <T> T[] toArray(T[] tArr) {
|
||||
Joiner.checkNotNull(tArr);
|
||||
int size = size();
|
||||
if (tArr.length < size) {
|
||||
tArr = (T[]) ObjectArrays.newArray(tArr, size);
|
||||
} else if (tArr.length > size) {
|
||||
tArr[size] = null;
|
||||
}
|
||||
copyIntoArray(tArr, 0);
|
||||
return tArr;
|
||||
}
|
||||
}
|
29
sources/com/squareup/haha/guava/collect/ImmutableEntry.java
Normal file
29
sources/com/squareup/haha/guava/collect/ImmutableEntry.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package com.squareup.haha.guava.collect;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class ImmutableEntry<K, V> extends AbstractMapEntry<K, V> implements Serializable {
|
||||
private K key;
|
||||
private V value;
|
||||
|
||||
ImmutableEntry(K k, V v) {
|
||||
this.key = k;
|
||||
this.value = v;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.AbstractMapEntry, java.util.Map.Entry
|
||||
public final K getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.AbstractMapEntry, java.util.Map.Entry
|
||||
public final V getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.AbstractMapEntry, java.util.Map.Entry
|
||||
public final V setValue(V v) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
304
sources/com/squareup/haha/guava/collect/ImmutableList.java
Normal file
304
sources/com/squareup/haha/guava/collect/ImmutableList.java
Normal file
@@ -0,0 +1,304 @@
|
||||
package com.squareup.haha.guava.collect;
|
||||
|
||||
import com.squareup.haha.guava.base.Joiner;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.RandomAccess;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class ImmutableList<E> extends ImmutableCollection<E> implements List<E>, RandomAccess {
|
||||
static final ImmutableList<Object> EMPTY = new RegularImmutableList(ObjectArrays.EMPTY_ARRAY);
|
||||
|
||||
static class ReverseImmutableList<E> extends ImmutableList<E> {
|
||||
private final transient ImmutableList<E> forwardList;
|
||||
|
||||
ReverseImmutableList(ImmutableList<E> immutableList) {
|
||||
this.forwardList = immutableList;
|
||||
}
|
||||
|
||||
private int reverseIndex(int i) {
|
||||
return (size() - 1) - i;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableList, com.squareup.haha.guava.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.util.List
|
||||
public final boolean contains(Object obj) {
|
||||
return this.forwardList.contains(obj);
|
||||
}
|
||||
|
||||
@Override // java.util.List
|
||||
public final E get(int i) {
|
||||
Joiner.checkElementIndex(i, size());
|
||||
return this.forwardList.get(reverseIndex(i));
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.List
|
||||
public final int indexOf(Object obj) {
|
||||
int lastIndexOf = this.forwardList.lastIndexOf(obj);
|
||||
if (lastIndexOf >= 0) {
|
||||
return reverseIndex(lastIndexOf);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableCollection
|
||||
final boolean isPartialView() {
|
||||
return this.forwardList.isPartialView();
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableList, com.squareup.haha.guava.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
|
||||
public final /* bridge */ /* synthetic */ Iterator iterator() {
|
||||
return super.iterator();
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.List
|
||||
public final int lastIndexOf(Object obj) {
|
||||
int indexOf = this.forwardList.indexOf(obj);
|
||||
if (indexOf >= 0) {
|
||||
return reverseIndex(indexOf);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.List
|
||||
public final /* bridge */ /* synthetic */ ListIterator listIterator(int i) {
|
||||
return super.listIterator(i);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableList
|
||||
public final ImmutableList<E> reverse() {
|
||||
return this.forwardList;
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
|
||||
public final int size() {
|
||||
return this.forwardList.size();
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.List
|
||||
public final /* bridge */ /* synthetic */ ListIterator listIterator() {
|
||||
return listIterator(0);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.List
|
||||
public final ImmutableList<E> subList(int i, int i2) {
|
||||
Joiner.checkPositionIndexes(i, i2, size());
|
||||
return this.forwardList.subList(size() - i2, size() - i).reverse();
|
||||
}
|
||||
}
|
||||
|
||||
class SubList extends ImmutableList<E> {
|
||||
private transient int length;
|
||||
private transient int offset;
|
||||
|
||||
SubList(int i, int i2) {
|
||||
this.offset = i;
|
||||
this.length = i2;
|
||||
}
|
||||
|
||||
@Override // java.util.List
|
||||
public final E get(int i) {
|
||||
Joiner.checkElementIndex(i, this.length);
|
||||
return ImmutableList.this.get(i + this.offset);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableCollection
|
||||
final boolean isPartialView() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableList, com.squareup.haha.guava.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
|
||||
public final /* bridge */ /* synthetic */ Iterator iterator() {
|
||||
return super.iterator();
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.List
|
||||
public final /* bridge */ /* synthetic */ ListIterator listIterator(int i) {
|
||||
return super.listIterator(i);
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
|
||||
public final int size() {
|
||||
return this.length;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.List
|
||||
public final /* bridge */ /* synthetic */ ListIterator listIterator() {
|
||||
return listIterator(0);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.List
|
||||
public final ImmutableList<E> subList(int i, int i2) {
|
||||
Joiner.checkPositionIndexes(i, i2, this.length);
|
||||
ImmutableList immutableList = ImmutableList.this;
|
||||
int i3 = this.offset;
|
||||
return immutableList.subList(i + i3, i2 + i3);
|
||||
}
|
||||
}
|
||||
|
||||
ImmutableList() {
|
||||
}
|
||||
|
||||
static <E> ImmutableList<E> asImmutableList(Object[] objArr) {
|
||||
int length = objArr.length;
|
||||
if (length == 0) {
|
||||
return (ImmutableList<E>) EMPTY;
|
||||
}
|
||||
if (length == 1) {
|
||||
return new SingletonImmutableList(objArr[0]);
|
||||
}
|
||||
if (length < objArr.length) {
|
||||
objArr = ObjectArrays.arraysCopyOf(objArr, length);
|
||||
}
|
||||
return new RegularImmutableList(objArr);
|
||||
}
|
||||
|
||||
public static <E> ImmutableList<E> copyOf(Collection<? extends E> collection) {
|
||||
if (!(collection instanceof ImmutableCollection)) {
|
||||
return asImmutableList(ObjectArrays.checkElementsNotNull(collection.toArray()));
|
||||
}
|
||||
ImmutableList<E> asList = ((ImmutableCollection) collection).asList();
|
||||
return asList.isPartialView() ? asImmutableList(asList.toArray()) : asList;
|
||||
}
|
||||
|
||||
public static <E> ImmutableList<E> of() {
|
||||
return (ImmutableList<E>) EMPTY;
|
||||
}
|
||||
|
||||
@Override // java.util.List
|
||||
@Deprecated
|
||||
public final void add(int i, E e) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.util.List
|
||||
@Deprecated
|
||||
public final boolean addAll(int i, Collection<? extends E> collection) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableCollection
|
||||
public final ImmutableList<E> asList() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.util.List
|
||||
public boolean contains(Object obj) {
|
||||
return indexOf(obj) >= 0;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableCollection
|
||||
int copyIntoArray(Object[] objArr, int i) {
|
||||
int size = size();
|
||||
for (int i2 = 0; i2 < size; i2++) {
|
||||
objArr[i + i2] = get(i2);
|
||||
}
|
||||
return i + size;
|
||||
}
|
||||
|
||||
@Override // java.util.Collection, java.util.List
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == Joiner.checkNotNull(this)) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof List)) {
|
||||
return false;
|
||||
}
|
||||
List list = (List) obj;
|
||||
return size() == list.size() && Iterators.elementsEqual(iterator(), list.iterator());
|
||||
}
|
||||
|
||||
@Override // java.util.Collection, java.util.List
|
||||
public int hashCode() {
|
||||
int size = size();
|
||||
int i = 1;
|
||||
for (int i2 = 0; i2 < size; i2++) {
|
||||
i = ~(~((i * 31) + get(i2).hashCode()));
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override // java.util.List
|
||||
public int indexOf(Object obj) {
|
||||
if (obj == null) {
|
||||
return -1;
|
||||
}
|
||||
ListIterator<E> listIterator = listIterator();
|
||||
while (listIterator.hasNext()) {
|
||||
if (Joiner.equal(obj, listIterator.next())) {
|
||||
return listIterator.previousIndex();
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override // java.util.List
|
||||
public int lastIndexOf(Object obj) {
|
||||
if (obj == null) {
|
||||
return -1;
|
||||
}
|
||||
ListIterator<E> listIterator = listIterator(size());
|
||||
while (listIterator.hasPrevious()) {
|
||||
if (Joiner.equal(obj, listIterator.previous())) {
|
||||
return listIterator.nextIndex();
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override // java.util.List
|
||||
@Deprecated
|
||||
public final E remove(int i) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public ImmutableList<E> reverse() {
|
||||
return new ReverseImmutableList(this);
|
||||
}
|
||||
|
||||
@Override // java.util.List
|
||||
@Deprecated
|
||||
public final E set(int i, E e) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
ImmutableList<E> subListUnchecked(int i, int i2) {
|
||||
return new SubList(i, i2 - i);
|
||||
}
|
||||
|
||||
public static <E> ImmutableList<E> of(E e) {
|
||||
return new SingletonImmutableList(e);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
|
||||
public UnmodifiableIterator<E> iterator() {
|
||||
return listIterator(0);
|
||||
}
|
||||
|
||||
@Override // java.util.List
|
||||
public UnmodifiableListIterator<E> listIterator(int i) {
|
||||
return new AbstractIndexedListIterator<E>(size(), i) { // from class: com.squareup.haha.guava.collect.ImmutableList.1
|
||||
@Override // com.squareup.haha.guava.collect.AbstractIndexedListIterator
|
||||
protected final E get(int i2) {
|
||||
return ImmutableList.this.get(i2);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override // java.util.List
|
||||
public ImmutableList<E> subList(int i, int i2) {
|
||||
Joiner.checkPositionIndexes(i, i2, size());
|
||||
int i3 = i2 - i;
|
||||
return i3 != 0 ? i3 != 1 ? subListUnchecked(i, i2) : of((Object) get(i)) : (ImmutableList<E>) EMPTY;
|
||||
}
|
||||
|
||||
public static <E> ImmutableList<E> of(E e, E e2) {
|
||||
return asImmutableList(ObjectArrays.checkElementsNotNull(e, e2));
|
||||
}
|
||||
|
||||
@Override // java.util.List
|
||||
public /* bridge */ /* synthetic */ ListIterator listIterator() {
|
||||
return listIterator(0);
|
||||
}
|
||||
}
|
31
sources/com/squareup/haha/guava/collect/Iterables.java
Normal file
31
sources/com/squareup/haha/guava/collect/Iterables.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package com.squareup.haha.guava.collect;
|
||||
|
||||
import com.squareup.haha.guava.base.Joiner;
|
||||
import java.util.Iterator;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class Iterables {
|
||||
static /* synthetic */ Iterator access$100(Iterable iterable) {
|
||||
return new TransformedIterator<Iterable<? extends T>, Iterator<? extends T>>(iterable.iterator()) { // from class: com.squareup.haha.guava.collect.Iterables.3
|
||||
@Override // com.squareup.haha.guava.collect.TransformedIterator
|
||||
final /* bridge */ /* synthetic */ Object transform(Object obj) {
|
||||
return ((Iterable) obj).iterator();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static <T> Iterable<T> concat(Iterable<? extends T> iterable, Iterable<? extends T> iterable2) {
|
||||
final ImmutableList of = ImmutableList.of(iterable, iterable2);
|
||||
Joiner.checkNotNull(of);
|
||||
return new FluentIterable<T>() { // from class: com.squareup.haha.guava.collect.Iterables.2
|
||||
@Override // java.lang.Iterable
|
||||
public final Iterator<T> iterator() {
|
||||
return Iterators.concat(Iterables.access$100(of));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static String toString(Iterable<?> iterable) {
|
||||
return Iterators.toString(iterable.iterator());
|
||||
}
|
||||
}
|
184
sources/com/squareup/haha/guava/collect/Iterators.java
Normal file
184
sources/com/squareup/haha/guava/collect/Iterators.java
Normal file
@@ -0,0 +1,184 @@
|
||||
package com.squareup.haha.guava.collect;
|
||||
|
||||
import com.squareup.haha.guava.base.Function;
|
||||
import com.squareup.haha.guava.base.Joiner;
|
||||
import com.squareup.haha.guava.base.Predicate;
|
||||
import com.squareup.haha.guava.base.Predicates;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class Iterators {
|
||||
private static UnmodifiableListIterator<Object> EMPTY_LIST_ITERATOR = new UnmodifiableListIterator<Object>() { // from class: com.squareup.haha.guava.collect.Iterators.1
|
||||
@Override // java.util.Iterator, java.util.ListIterator
|
||||
public final boolean hasNext() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // java.util.ListIterator
|
||||
public final boolean hasPrevious() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator, java.util.ListIterator
|
||||
public final Object next() {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
@Override // java.util.ListIterator
|
||||
public final int nextIndex() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override // java.util.ListIterator
|
||||
public final Object previous() {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
@Override // java.util.ListIterator
|
||||
public final int previousIndex() {
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
private static final Iterator<Object> EMPTY_MODIFIABLE_ITERATOR = new Iterator<Object>() { // from class: com.squareup.haha.guava.collect.Iterators.2
|
||||
@Override // java.util.Iterator
|
||||
public final boolean hasNext() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public final Object next() {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public final void remove() {
|
||||
Joiner.checkRemove(false);
|
||||
}
|
||||
};
|
||||
|
||||
static void clear(Iterator<?> it) {
|
||||
Joiner.checkNotNull(it);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> Iterator<T> concat(final Iterator<? extends Iterator<? extends T>> it) {
|
||||
Joiner.checkNotNull(it);
|
||||
return new Iterator<T>() { // from class: com.squareup.haha.guava.collect.Iterators.5
|
||||
private Iterator<? extends T> current = Iterators.emptyIterator();
|
||||
private Iterator<? extends T> removeFrom;
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public final boolean hasNext() {
|
||||
boolean hasNext;
|
||||
while (true) {
|
||||
hasNext = ((Iterator) Joiner.checkNotNull(this.current)).hasNext();
|
||||
if (hasNext || !it.hasNext()) {
|
||||
break;
|
||||
}
|
||||
this.current = (Iterator) it.next();
|
||||
}
|
||||
return hasNext;
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public final T next() {
|
||||
if (!hasNext()) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
Iterator<? extends T> it2 = this.current;
|
||||
this.removeFrom = it2;
|
||||
return it2.next();
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public final void remove() {
|
||||
Joiner.checkRemove(this.removeFrom != null);
|
||||
this.removeFrom.remove();
|
||||
this.removeFrom = null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static boolean elementsEqual(Iterator<?> it, Iterator<?> it2) {
|
||||
while (it.hasNext()) {
|
||||
if (!it2.hasNext() || !Joiner.equal(it.next(), it2.next())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return !it2.hasNext();
|
||||
}
|
||||
|
||||
public static <T> UnmodifiableIterator<T> emptyIterator() {
|
||||
return EMPTY_LIST_ITERATOR;
|
||||
}
|
||||
|
||||
static <T> Iterator<T> emptyModifiableIterator() {
|
||||
return (Iterator<T>) EMPTY_MODIFIABLE_ITERATOR;
|
||||
}
|
||||
|
||||
static <T> UnmodifiableListIterator<T> forArray(final T[] tArr, final int i, int i2, int i3) {
|
||||
Joiner.checkArgument(i2 >= 0);
|
||||
Joiner.checkPositionIndexes(i, i + i2, tArr.length);
|
||||
Joiner.checkPositionIndex(i3, i2);
|
||||
return i2 == 0 ? (UnmodifiableListIterator<T>) EMPTY_LIST_ITERATOR : new AbstractIndexedListIterator<T>(i2, i3) { // from class: com.squareup.haha.guava.collect.Iterators.11
|
||||
@Override // com.squareup.haha.guava.collect.AbstractIndexedListIterator
|
||||
protected final T get(int i4) {
|
||||
return (T) tArr[i + i4];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static boolean removeAll(Iterator<?> it, Collection<?> collection) {
|
||||
Predicate in = Predicates.in(collection);
|
||||
Joiner.checkNotNull(in);
|
||||
boolean z = false;
|
||||
while (it.hasNext()) {
|
||||
if (in.apply(it.next())) {
|
||||
it.remove();
|
||||
z = true;
|
||||
}
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
public static <T> UnmodifiableIterator<T> singletonIterator(final T t) {
|
||||
return new UnmodifiableIterator<T>() { // from class: com.squareup.haha.guava.collect.Iterators.12
|
||||
private boolean done;
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public final boolean hasNext() {
|
||||
return !this.done;
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public final T next() {
|
||||
if (this.done) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
this.done = true;
|
||||
return (T) t;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static String toString(Iterator<?> it) {
|
||||
StringBuilder appendTo = Collections2.STANDARD_JOINER.appendTo(new StringBuilder("["), it);
|
||||
appendTo.append(']');
|
||||
return appendTo.toString();
|
||||
}
|
||||
|
||||
public static <F, T> Iterator<T> transform(Iterator<F> it, final Function<? super F, ? extends T> function) {
|
||||
Joiner.checkNotNull(function);
|
||||
return new TransformedIterator<F, T>(it) { // from class: com.squareup.haha.guava.collect.Iterators.8
|
||||
@Override // com.squareup.haha.guava.collect.TransformedIterator
|
||||
final T transform(F f) {
|
||||
return (T) function.apply(f);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
package com.squareup.haha.guava.collect;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface ListMultimap extends Multimap {
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
package com.squareup.haha.guava.collect;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.RandomAccess;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class Lists$RandomAccessReverseList<T> extends Lists$ReverseList<T> implements RandomAccess {
|
||||
public Lists$RandomAccessReverseList(List<T> list) {
|
||||
super(list);
|
||||
}
|
||||
}
|
144
sources/com/squareup/haha/guava/collect/Lists$ReverseList.java
Normal file
144
sources/com/squareup/haha/guava/collect/Lists$ReverseList.java
Normal file
@@ -0,0 +1,144 @@
|
||||
package com.squareup.haha.guava.collect;
|
||||
|
||||
import com.squareup.haha.guava.base.Joiner;
|
||||
import java.util.AbstractList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Lists$ReverseList<T> extends AbstractList<T> {
|
||||
public final List<T> forwardList;
|
||||
|
||||
public Lists$ReverseList(List<T> list) {
|
||||
this.forwardList = (List) Joiner.checkNotNull(list);
|
||||
}
|
||||
|
||||
private int reverseIndex(int i) {
|
||||
int size = size();
|
||||
Joiner.checkElementIndex(i, size);
|
||||
return (size - 1) - i;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public int reversePosition(int i) {
|
||||
int size = size();
|
||||
Joiner.checkPositionIndex(i, size);
|
||||
return size - i;
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractList, java.util.List
|
||||
public void add(int i, T t) {
|
||||
this.forwardList.add(reversePosition(i), t);
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractList, java.util.AbstractCollection, java.util.Collection, java.util.List
|
||||
public void clear() {
|
||||
this.forwardList.clear();
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractList, java.util.List
|
||||
public T get(int i) {
|
||||
return this.forwardList.get(reverseIndex(i));
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractList, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.List
|
||||
public Iterator<T> iterator() {
|
||||
return listIterator();
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractList, java.util.List
|
||||
public ListIterator<T> listIterator(int i) {
|
||||
final ListIterator<T> listIterator = this.forwardList.listIterator(reversePosition(i));
|
||||
return new ListIterator<T>() { // from class: com.squareup.haha.guava.collect.Lists$ReverseList.1
|
||||
private boolean canRemoveOrSet;
|
||||
|
||||
@Override // java.util.ListIterator
|
||||
public final void add(T t) {
|
||||
listIterator.add(t);
|
||||
listIterator.previous();
|
||||
this.canRemoveOrSet = false;
|
||||
}
|
||||
|
||||
@Override // java.util.ListIterator, java.util.Iterator
|
||||
public final boolean hasNext() {
|
||||
return listIterator.hasPrevious();
|
||||
}
|
||||
|
||||
@Override // java.util.ListIterator
|
||||
public final boolean hasPrevious() {
|
||||
return listIterator.hasNext();
|
||||
}
|
||||
|
||||
@Override // java.util.ListIterator, java.util.Iterator
|
||||
public final T next() {
|
||||
if (!hasNext()) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
this.canRemoveOrSet = true;
|
||||
return (T) listIterator.previous();
|
||||
}
|
||||
|
||||
@Override // java.util.ListIterator
|
||||
public final int nextIndex() {
|
||||
return Lists$ReverseList.this.reversePosition(listIterator.nextIndex());
|
||||
}
|
||||
|
||||
@Override // java.util.ListIterator
|
||||
public final T previous() {
|
||||
if (!hasPrevious()) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
this.canRemoveOrSet = true;
|
||||
return (T) listIterator.next();
|
||||
}
|
||||
|
||||
@Override // java.util.ListIterator
|
||||
public final int previousIndex() {
|
||||
return nextIndex() - 1;
|
||||
}
|
||||
|
||||
@Override // java.util.ListIterator, java.util.Iterator
|
||||
public final void remove() {
|
||||
Joiner.checkRemove(this.canRemoveOrSet);
|
||||
listIterator.remove();
|
||||
this.canRemoveOrSet = false;
|
||||
}
|
||||
|
||||
@Override // java.util.ListIterator
|
||||
public final void set(T t) {
|
||||
if (!this.canRemoveOrSet) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
listIterator.set(t);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractList, java.util.List
|
||||
public T remove(int i) {
|
||||
return this.forwardList.remove(reverseIndex(i));
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractList
|
||||
protected void removeRange(int i, int i2) {
|
||||
subList(i, i2).clear();
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractList, java.util.List
|
||||
public T set(int i, T t) {
|
||||
return this.forwardList.set(reverseIndex(i), t);
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
|
||||
public int size() {
|
||||
return this.forwardList.size();
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractList, java.util.List
|
||||
public List<T> subList(int i, int i2) {
|
||||
Joiner.checkPositionIndexes(i, i2, size());
|
||||
return Joiner.reverse(this.forwardList.subList(reversePosition(i2), reversePosition(i)));
|
||||
}
|
||||
}
|
349
sources/com/squareup/haha/guava/collect/Maps.java
Normal file
349
sources/com/squareup/haha/guava/collect/Maps.java
Normal file
@@ -0,0 +1,349 @@
|
||||
package com.squareup.haha.guava.collect;
|
||||
|
||||
import com.squareup.haha.guava.base.Function;
|
||||
import com.squareup.haha.guava.base.Joiner;
|
||||
import java.util.AbstractCollection;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class Maps {
|
||||
|
||||
/* JADX WARN: $VALUES field not found */
|
||||
/* JADX WARN: Failed to restore enum class, 'enum' modifier and super class removed */
|
||||
static abstract class EntryFunction implements Function<Map.Entry<?, ?>, Object> {
|
||||
public static final EntryFunction KEY = new EntryFunction("KEY", 0) { // from class: com.squareup.haha.guava.collect.Maps.EntryFunction.1
|
||||
{
|
||||
byte b = 0;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.base.Function
|
||||
public final /* bridge */ /* synthetic */ Object apply(Map.Entry<?, ?> entry) {
|
||||
return entry.getKey();
|
||||
}
|
||||
};
|
||||
public static final EntryFunction VALUE = new EntryFunction("VALUE", 1) { // from class: com.squareup.haha.guava.collect.Maps.EntryFunction.2
|
||||
{
|
||||
int i = 1;
|
||||
byte b = 0;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.base.Function
|
||||
public final /* bridge */ /* synthetic */ Object apply(Map.Entry<?, ?> entry) {
|
||||
return entry.getValue();
|
||||
}
|
||||
};
|
||||
|
||||
static {
|
||||
EntryFunction[] entryFunctionArr = {KEY, VALUE};
|
||||
}
|
||||
|
||||
private EntryFunction(String str, int i) {
|
||||
}
|
||||
|
||||
/* synthetic */ EntryFunction(String str, int i, byte b) {
|
||||
this(str, i);
|
||||
}
|
||||
}
|
||||
|
||||
static abstract class EntrySet<K, V> extends Sets$ImprovedAbstractSet<Map.Entry<K, V>> {
|
||||
EntrySet() {
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
||||
public void clear() {
|
||||
map().clear();
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
||||
public boolean contains(Object obj) {
|
||||
if (obj instanceof Map.Entry) {
|
||||
Map.Entry entry = (Map.Entry) obj;
|
||||
Object key = entry.getKey();
|
||||
Object safeGet = Maps.safeGet(map(), key);
|
||||
if (Joiner.equal(safeGet, entry.getValue()) && (safeGet != null || map().containsKey(key))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
||||
public boolean isEmpty() {
|
||||
return map().isEmpty();
|
||||
}
|
||||
|
||||
abstract Map<K, V> map();
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
||||
public boolean remove(Object obj) {
|
||||
if (contains(obj)) {
|
||||
return map().keySet().remove(((Map.Entry) obj).getKey());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.Sets$ImprovedAbstractSet, java.util.AbstractSet, java.util.AbstractCollection, java.util.Collection, java.util.Set
|
||||
public boolean removeAll(Collection<?> collection) {
|
||||
try {
|
||||
return super.removeAll((Collection) Joiner.checkNotNull(collection));
|
||||
} catch (UnsupportedOperationException unused) {
|
||||
return Joiner.removeAllImpl(this, collection.iterator());
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.Sets$ImprovedAbstractSet, java.util.AbstractCollection, java.util.Collection, java.util.Set
|
||||
public boolean retainAll(Collection<?> collection) {
|
||||
try {
|
||||
return super.retainAll((Collection) Joiner.checkNotNull(collection));
|
||||
} catch (UnsupportedOperationException unused) {
|
||||
HashSet hashSet = new HashSet(Maps.capacity(collection.size()));
|
||||
for (Object obj : collection) {
|
||||
if (contains(obj)) {
|
||||
hashSet.add(((Map.Entry) obj).getKey());
|
||||
}
|
||||
}
|
||||
return map().keySet().retainAll(hashSet);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
||||
public int size() {
|
||||
return map().size();
|
||||
}
|
||||
}
|
||||
|
||||
static abstract class ImprovedAbstractMap<K, V> extends AbstractMap<K, V> {
|
||||
private transient Set<Map.Entry<K, V>> entrySet;
|
||||
private transient Set<K> keySet;
|
||||
private transient Collection<V> values;
|
||||
|
||||
ImprovedAbstractMap() {
|
||||
}
|
||||
|
||||
abstract Set<Map.Entry<K, V>> createEntrySet();
|
||||
|
||||
/* renamed from: createKeySet */
|
||||
Set<K> mo16createKeySet() {
|
||||
return new KeySet(this);
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractMap, java.util.Map
|
||||
public Set<Map.Entry<K, V>> entrySet() {
|
||||
Set<Map.Entry<K, V>> set = this.entrySet;
|
||||
if (set != null) {
|
||||
return set;
|
||||
}
|
||||
Set<Map.Entry<K, V>> createEntrySet = createEntrySet();
|
||||
this.entrySet = createEntrySet;
|
||||
return createEntrySet;
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractMap, java.util.Map
|
||||
public Set<K> keySet() {
|
||||
Set<K> set = this.keySet;
|
||||
if (set != null) {
|
||||
return set;
|
||||
}
|
||||
Set<K> mo16createKeySet = mo16createKeySet();
|
||||
this.keySet = mo16createKeySet;
|
||||
return mo16createKeySet;
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractMap, java.util.Map
|
||||
public Collection<V> values() {
|
||||
Collection<V> collection = this.values;
|
||||
if (collection != null) {
|
||||
return collection;
|
||||
}
|
||||
Values values = new Values(this);
|
||||
this.values = values;
|
||||
return values;
|
||||
}
|
||||
}
|
||||
|
||||
static class KeySet<K, V> extends Sets$ImprovedAbstractSet<K> {
|
||||
final Map<K, V> map;
|
||||
|
||||
KeySet(Map<K, V> map) {
|
||||
this.map = (Map) Joiner.checkNotNull(map);
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
||||
public void clear() {
|
||||
this.map.clear();
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
||||
public boolean contains(Object obj) {
|
||||
return this.map.containsKey(obj);
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
||||
public boolean isEmpty() {
|
||||
return this.map.isEmpty();
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
|
||||
public Iterator<K> iterator() {
|
||||
return Maps.keyIterator(this.map.entrySet().iterator());
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
||||
public boolean remove(Object obj) {
|
||||
if (!contains(obj)) {
|
||||
return false;
|
||||
}
|
||||
this.map.remove(obj);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
||||
public int size() {
|
||||
return this.map.size();
|
||||
}
|
||||
}
|
||||
|
||||
static class Values<K, V> extends AbstractCollection<V> {
|
||||
private Map<K, V> map;
|
||||
|
||||
Values(Map<K, V> map) {
|
||||
this.map = (Map) Joiner.checkNotNull(map);
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection
|
||||
public final void clear() {
|
||||
this.map.clear();
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection
|
||||
public final boolean contains(Object obj) {
|
||||
return this.map.containsValue(obj);
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection
|
||||
public final boolean isEmpty() {
|
||||
return this.map.isEmpty();
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
|
||||
public final Iterator<V> iterator() {
|
||||
return Maps.valueIterator(this.map.entrySet().iterator());
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection
|
||||
public final boolean remove(Object obj) {
|
||||
try {
|
||||
return super.remove(obj);
|
||||
} catch (UnsupportedOperationException unused) {
|
||||
for (Map.Entry<K, V> entry : this.map.entrySet()) {
|
||||
if (Joiner.equal(obj, entry.getValue())) {
|
||||
this.map.remove(entry.getKey());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection
|
||||
public final boolean removeAll(Collection<?> collection) {
|
||||
try {
|
||||
return super.removeAll((Collection) Joiner.checkNotNull(collection));
|
||||
} catch (UnsupportedOperationException unused) {
|
||||
HashSet hashSet = new HashSet();
|
||||
for (Map.Entry<K, V> entry : this.map.entrySet()) {
|
||||
if (collection.contains(entry.getValue())) {
|
||||
hashSet.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
return this.map.keySet().removeAll(hashSet);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection
|
||||
public final boolean retainAll(Collection<?> collection) {
|
||||
try {
|
||||
return super.retainAll((Collection) Joiner.checkNotNull(collection));
|
||||
} catch (UnsupportedOperationException unused) {
|
||||
HashSet hashSet = new HashSet();
|
||||
for (Map.Entry<K, V> entry : this.map.entrySet()) {
|
||||
if (collection.contains(entry.getValue())) {
|
||||
hashSet.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
return this.map.keySet().retainAll(hashSet);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection
|
||||
public final int size() {
|
||||
return this.map.size();
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
new Joiner.MapJoiner(Collections2.STANDARD_JOINER, "=", (byte) 0);
|
||||
}
|
||||
|
||||
public static int capacity(int i) {
|
||||
if (i >= 3) {
|
||||
if (i < 1073741824) {
|
||||
return i + (i / 3);
|
||||
}
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
if (i >= 0) {
|
||||
return i + 1;
|
||||
}
|
||||
throw new IllegalArgumentException("expectedSize cannot be negative but was: " + i);
|
||||
}
|
||||
|
||||
public static <K, V> Map.Entry<K, V> immutableEntry(K k, V v) {
|
||||
return new ImmutableEntry(k, v);
|
||||
}
|
||||
|
||||
static <K, V> Iterator<K> keyIterator(Iterator<Map.Entry<K, V>> it) {
|
||||
return Iterators.transform(it, EntryFunction.KEY);
|
||||
}
|
||||
|
||||
public static <K, V> HashMap<K, V> newHashMap() {
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
static boolean safeContainsKey(Map<?, ?> map, Object obj) {
|
||||
Joiner.checkNotNull(map);
|
||||
try {
|
||||
return map.containsKey(obj);
|
||||
} catch (ClassCastException | NullPointerException unused) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static <V> V safeGet(Map<?, V> map, Object obj) {
|
||||
Joiner.checkNotNull(map);
|
||||
try {
|
||||
return map.get(obj);
|
||||
} catch (ClassCastException | NullPointerException unused) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static <V> V safeRemove(Map<?, V> map, Object obj) {
|
||||
Joiner.checkNotNull(map);
|
||||
try {
|
||||
return map.remove(obj);
|
||||
} catch (ClassCastException | NullPointerException unused) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static <K, V> Iterator<V> valueIterator(Iterator<Map.Entry<K, V>> it) {
|
||||
return Iterators.transform(it, EntryFunction.VALUE);
|
||||
}
|
||||
}
|
23
sources/com/squareup/haha/guava/collect/Multimap.java
Normal file
23
sources/com/squareup/haha/guava/collect/Multimap.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package com.squareup.haha.guava.collect;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface Multimap<K, V> {
|
||||
Map<K, Collection<V>> asMap();
|
||||
|
||||
void clear();
|
||||
|
||||
boolean containsEntry(Object obj, Object obj2);
|
||||
|
||||
Collection<V> get(K k);
|
||||
|
||||
boolean put(K k, V v);
|
||||
|
||||
boolean remove(Object obj, Object obj2);
|
||||
|
||||
int size();
|
||||
|
||||
Collection<V> values();
|
||||
}
|
9
sources/com/squareup/haha/guava/collect/Multiset.java
Normal file
9
sources/com/squareup/haha/guava/collect/Multiset.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package com.squareup.haha.guava.collect;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface Multiset<E> extends Collection<E> {
|
||||
Set<E> elementSet();
|
||||
}
|
28
sources/com/squareup/haha/guava/collect/ObjectArrays.java
Normal file
28
sources/com/squareup/haha/guava/collect/ObjectArrays.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.squareup.haha.guava.collect;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class ObjectArrays {
|
||||
static final Object[] EMPTY_ARRAY = new Object[0];
|
||||
|
||||
static <T> T[] arraysCopyOf(T[] tArr, int i) {
|
||||
T[] tArr2 = (T[]) newArray(tArr, i);
|
||||
System.arraycopy(tArr, 0, tArr2, 0, Math.min(tArr.length, i));
|
||||
return tArr2;
|
||||
}
|
||||
|
||||
static Object[] checkElementsNotNull(Object... objArr) {
|
||||
int length = objArr.length;
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (objArr[i] == null) {
|
||||
throw new NullPointerException("at index " + i);
|
||||
}
|
||||
}
|
||||
return objArr;
|
||||
}
|
||||
|
||||
public static <T> T[] newArray(T[] tArr, int i) {
|
||||
return (T[]) ((Object[]) Array.newInstance(tArr.getClass().getComponentType(), i));
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
package com.squareup.haha.guava.collect;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class RegularImmutableAsList<E> extends ImmutableAsList<E> {
|
||||
private final ImmutableCollection<E> delegate;
|
||||
private final ImmutableList<? extends E> delegateList;
|
||||
|
||||
private RegularImmutableAsList(ImmutableCollection<E> immutableCollection, ImmutableList<? extends E> immutableList) {
|
||||
this.delegate = immutableCollection;
|
||||
this.delegateList = immutableList;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableList, com.squareup.haha.guava.collect.ImmutableCollection
|
||||
final int copyIntoArray(Object[] objArr, int i) {
|
||||
return this.delegateList.copyIntoArray(objArr, i);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableAsList
|
||||
final ImmutableCollection<E> delegateCollection() {
|
||||
return this.delegate;
|
||||
}
|
||||
|
||||
@Override // java.util.List
|
||||
public final E get(int i) {
|
||||
return this.delegateList.get(i);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.List
|
||||
public final UnmodifiableListIterator<E> listIterator(int i) {
|
||||
return this.delegateList.listIterator(i);
|
||||
}
|
||||
|
||||
RegularImmutableAsList(ImmutableCollection<E> immutableCollection, Object[] objArr) {
|
||||
this(immutableCollection, ImmutableList.asImmutableList(objArr));
|
||||
}
|
||||
}
|
@@ -0,0 +1,78 @@
|
||||
package com.squareup.haha.guava.collect;
|
||||
|
||||
import com.squareup.haha.guava.base.Joiner;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class RegularImmutableList<E> extends ImmutableList<E> {
|
||||
private final transient Object[] array;
|
||||
private final transient int offset;
|
||||
private final transient int size;
|
||||
|
||||
private RegularImmutableList(Object[] objArr, int i, int i2) {
|
||||
this.offset = i;
|
||||
this.size = i2;
|
||||
this.array = objArr;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableList, com.squareup.haha.guava.collect.ImmutableCollection
|
||||
final int copyIntoArray(Object[] objArr, int i) {
|
||||
System.arraycopy(this.array, this.offset, objArr, i, this.size);
|
||||
return i + this.size;
|
||||
}
|
||||
|
||||
@Override // java.util.List
|
||||
public final E get(int i) {
|
||||
Joiner.checkElementIndex(i, this.size);
|
||||
return (E) this.array[i + this.offset];
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.List
|
||||
public final int indexOf(Object obj) {
|
||||
if (obj == null) {
|
||||
return -1;
|
||||
}
|
||||
for (int i = 0; i < this.size; i++) {
|
||||
if (this.array[this.offset + i].equals(obj)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableCollection
|
||||
final boolean isPartialView() {
|
||||
return this.size != this.array.length;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.List
|
||||
public final int lastIndexOf(Object obj) {
|
||||
if (obj == null) {
|
||||
return -1;
|
||||
}
|
||||
for (int i = this.size - 1; i >= 0; i--) {
|
||||
if (this.array[this.offset + i].equals(obj)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
|
||||
public final int size() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableList
|
||||
final ImmutableList<E> subListUnchecked(int i, int i2) {
|
||||
return new RegularImmutableList(this.array, this.offset + i, i2 - i);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.List
|
||||
public final UnmodifiableListIterator<E> listIterator(int i) {
|
||||
return Iterators.forArray(this.array, this.offset, this.size, i);
|
||||
}
|
||||
|
||||
RegularImmutableList(Object[] objArr) {
|
||||
this(objArr, 0, objArr.length);
|
||||
}
|
||||
}
|
5
sources/com/squareup/haha/guava/collect/SetMultimap.java
Normal file
5
sources/com/squareup/haha/guava/collect/SetMultimap.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package com.squareup.haha.guava.collect;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface SetMultimap<K, V> extends Multimap<K, V> {
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
package com.squareup.haha.guava.collect;
|
||||
|
||||
import com.squareup.haha.guava.base.Joiner;
|
||||
import java.util.AbstractSet;
|
||||
import java.util.Collection;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
abstract class Sets$ImprovedAbstractSet<E> extends AbstractSet<E> {
|
||||
Sets$ImprovedAbstractSet() {
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractSet, java.util.AbstractCollection, java.util.Collection, java.util.Set
|
||||
public boolean removeAll(Collection<?> collection) {
|
||||
return Joiner.removeAllImpl(this, collection);
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
||||
public boolean retainAll(Collection<?> collection) {
|
||||
return super.retainAll((Collection) Joiner.checkNotNull(collection));
|
||||
}
|
||||
}
|
@@ -0,0 +1,106 @@
|
||||
package com.squareup.haha.guava.collect;
|
||||
|
||||
import com.squareup.haha.guava.base.Joiner;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class SingletonImmutableList<E> extends ImmutableList<E> {
|
||||
private transient E element;
|
||||
|
||||
SingletonImmutableList(E e) {
|
||||
this.element = (E) Joiner.checkNotNull(e);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableList, com.squareup.haha.guava.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.util.List
|
||||
public final boolean contains(Object obj) {
|
||||
return this.element.equals(obj);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableList, com.squareup.haha.guava.collect.ImmutableCollection
|
||||
final int copyIntoArray(Object[] objArr, int i) {
|
||||
objArr[i] = this.element;
|
||||
return i + 1;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.Collection, java.util.List
|
||||
public final boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof List) {
|
||||
List list = (List) obj;
|
||||
if (list.size() == 1 && this.element.equals(list.get(0))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // java.util.List
|
||||
public final E get(int i) {
|
||||
Joiner.checkElementIndex(i, 1);
|
||||
return this.element;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.Collection, java.util.List
|
||||
public final int hashCode() {
|
||||
return this.element.hashCode() + 31;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.List
|
||||
public final int indexOf(Object obj) {
|
||||
return this.element.equals(obj) ? 0 : -1;
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
|
||||
public final boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableCollection
|
||||
final boolean isPartialView() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableList, com.squareup.haha.guava.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
|
||||
public final UnmodifiableIterator<E> iterator() {
|
||||
return Iterators.singletonIterator(this.element);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.List
|
||||
public final int lastIndexOf(Object obj) {
|
||||
return indexOf(obj);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableList
|
||||
public final ImmutableList<E> reverse() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
|
||||
public final int size() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection
|
||||
public final String toString() {
|
||||
String obj = this.element.toString();
|
||||
StringBuilder sb = new StringBuilder(obj.length() + 2);
|
||||
sb.append('[');
|
||||
sb.append(obj);
|
||||
sb.append(']');
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableList, com.squareup.haha.guava.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
|
||||
public final /* bridge */ /* synthetic */ Iterator iterator() {
|
||||
return Iterators.singletonIterator(this.element);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.guava.collect.ImmutableList, java.util.List
|
||||
public final ImmutableList<E> subList(int i, int i2) {
|
||||
Joiner.checkPositionIndexes(i, i2, 1);
|
||||
return i == i2 ? (ImmutableList<E>) ImmutableList.EMPTY : this;
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
package com.squareup.haha.guava.collect;
|
||||
|
||||
import com.squareup.haha.guava.base.Joiner;
|
||||
import java.util.Iterator;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
abstract class TransformedIterator<F, T> implements Iterator<T> {
|
||||
private Iterator<? extends F> backingIterator;
|
||||
|
||||
TransformedIterator(Iterator<? extends F> it) {
|
||||
this.backingIterator = (Iterator) Joiner.checkNotNull(it);
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public final boolean hasNext() {
|
||||
return this.backingIterator.hasNext();
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public final T next() {
|
||||
return transform(this.backingIterator.next());
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public final void remove() {
|
||||
this.backingIterator.remove();
|
||||
}
|
||||
|
||||
abstract T transform(F f);
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
package com.squareup.haha.guava.collect;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class UnmodifiableIterator<E> implements Iterator<E> {
|
||||
protected UnmodifiableIterator() {
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator
|
||||
@Deprecated
|
||||
public final void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
package com.squareup.haha.guava.collect;
|
||||
|
||||
import java.util.ListIterator;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class UnmodifiableListIterator<E> extends UnmodifiableIterator<E> implements ListIterator<E> {
|
||||
protected UnmodifiableListIterator() {
|
||||
}
|
||||
|
||||
@Override // java.util.ListIterator
|
||||
@Deprecated
|
||||
public final void add(E e) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.util.ListIterator
|
||||
@Deprecated
|
||||
public final void set(E e) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
82
sources/com/squareup/haha/perflib/ArrayInstance.java
Normal file
82
sources/com/squareup/haha/perflib/ArrayInstance.java
Normal file
@@ -0,0 +1,82 @@
|
||||
package com.squareup.haha.perflib;
|
||||
|
||||
import com.squareup.haha.perflib.io.HprofBuffer;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ArrayInstance extends Instance {
|
||||
static final /* synthetic */ boolean $assertionsDisabled = false;
|
||||
private final int mLength;
|
||||
private final Type mType;
|
||||
private final long mValuesOffset;
|
||||
|
||||
public ArrayInstance(long j, StackTrace stackTrace, Type type, int i, long j2) {
|
||||
super(j, stackTrace);
|
||||
this.mType = type;
|
||||
this.mLength = i;
|
||||
this.mValuesOffset = j2;
|
||||
}
|
||||
|
||||
private byte[] asRawByteArray(int i, int i2) {
|
||||
getBuffer().setPosition(this.mValuesOffset);
|
||||
byte[] bArr = new byte[this.mType.getSize() * i2];
|
||||
getBuffer().readSubSequence(bArr, i * this.mType.getSize(), i2 * this.mType.getSize());
|
||||
return bArr;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.perflib.Instance
|
||||
public final void accept(Visitor visitor) {
|
||||
visitor.visitArrayInstance(this);
|
||||
if (this.mType == Type.OBJECT) {
|
||||
for (Object obj : getValues()) {
|
||||
if (obj instanceof Instance) {
|
||||
if (!this.mReferencesAdded) {
|
||||
((Instance) obj).addReference(null, this);
|
||||
}
|
||||
visitor.visitLater(this, (Instance) obj);
|
||||
}
|
||||
}
|
||||
this.mReferencesAdded = true;
|
||||
}
|
||||
}
|
||||
|
||||
public char[] asCharArray(int i, int i2) {
|
||||
CharBuffer asCharBuffer = ByteBuffer.wrap(asRawByteArray(i, i2)).order(HprofBuffer.HPROF_BYTE_ORDER).asCharBuffer();
|
||||
char[] cArr = new char[i2];
|
||||
asCharBuffer.get(cArr);
|
||||
return cArr;
|
||||
}
|
||||
|
||||
public Type getArrayType() {
|
||||
return this.mType;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.perflib.Instance
|
||||
public ClassObj getClassObj() {
|
||||
Type type = this.mType;
|
||||
return type == Type.OBJECT ? super.getClassObj() : this.mHeap.mSnapshot.findClass(Type.getClassNameOfPrimitiveArray(type));
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.perflib.Instance
|
||||
public final int getSize() {
|
||||
return this.mLength * this.mHeap.mSnapshot.getTypeSize(this.mType);
|
||||
}
|
||||
|
||||
public Object[] getValues() {
|
||||
Object[] objArr = new Object[this.mLength];
|
||||
getBuffer().setPosition(this.mValuesOffset);
|
||||
for (int i = 0; i < this.mLength; i++) {
|
||||
objArr[i] = readValue(this.mType);
|
||||
}
|
||||
return objArr;
|
||||
}
|
||||
|
||||
public final String toString() {
|
||||
String className = getClassObj().getClassName();
|
||||
if (className.endsWith("[]")) {
|
||||
className = className.substring(0, className.length() - 2);
|
||||
}
|
||||
return String.format("%s[%d]@%d (0x%x)", className, Integer.valueOf(this.mLength), Long.valueOf(getUniqueId()), Long.valueOf(getUniqueId()));
|
||||
}
|
||||
}
|
76
sources/com/squareup/haha/perflib/ClassInstance.java
Normal file
76
sources/com/squareup/haha/perflib/ClassInstance.java
Normal file
@@ -0,0 +1,76 @@
|
||||
package com.squareup.haha.perflib;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ClassInstance extends Instance {
|
||||
private final long mValuesOffset;
|
||||
|
||||
public static class FieldValue {
|
||||
private Field mField;
|
||||
private Object mValue;
|
||||
|
||||
public FieldValue(Field field, Object obj) {
|
||||
this.mField = field;
|
||||
this.mValue = obj;
|
||||
}
|
||||
|
||||
public Field getField() {
|
||||
return this.mField;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return this.mValue;
|
||||
}
|
||||
}
|
||||
|
||||
public ClassInstance(long j, StackTrace stackTrace, long j2) {
|
||||
super(j, stackTrace);
|
||||
this.mValuesOffset = j2;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.perflib.Instance
|
||||
public final void accept(Visitor visitor) {
|
||||
visitor.visitClassInstance(this);
|
||||
for (FieldValue fieldValue : getValues()) {
|
||||
if (fieldValue.getValue() instanceof Instance) {
|
||||
if (!this.mReferencesAdded) {
|
||||
((Instance) fieldValue.getValue()).addReference(fieldValue.getField(), this);
|
||||
}
|
||||
visitor.visitLater(this, (Instance) fieldValue.getValue());
|
||||
}
|
||||
}
|
||||
this.mReferencesAdded = true;
|
||||
}
|
||||
|
||||
List<FieldValue> getFields(String str) {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
for (FieldValue fieldValue : getValues()) {
|
||||
if (fieldValue.getField().getName().equals(str)) {
|
||||
arrayList.add(fieldValue);
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.perflib.Instance
|
||||
public boolean getIsSoftReference() {
|
||||
return getClassObj().getIsSoftReference();
|
||||
}
|
||||
|
||||
public List<FieldValue> getValues() {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
getBuffer().setPosition(this.mValuesOffset);
|
||||
for (ClassObj classObj = getClassObj(); classObj != null; classObj = classObj.getSuperClassObj()) {
|
||||
for (Field field : classObj.getFields()) {
|
||||
arrayList.add(new FieldValue(field, readValue(field.getType())));
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public final String toString() {
|
||||
return String.format("%s@%d (0x%x)", getClassObj().getClassName(), Long.valueOf(getUniqueId()), Long.valueOf(getUniqueId()));
|
||||
}
|
||||
}
|
260
sources/com/squareup/haha/perflib/ClassObj.java
Normal file
260
sources/com/squareup/haha/perflib/ClassObj.java
Normal file
@@ -0,0 +1,260 @@
|
||||
package com.squareup.haha.perflib;
|
||||
|
||||
import gnu.trove.TIntObjectHashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ClassObj extends Instance implements Comparable<ClassObj> {
|
||||
long mClassLoaderId;
|
||||
final String mClassName;
|
||||
Field[] mFields;
|
||||
TIntObjectHashMap<HeapData> mHeapData;
|
||||
private int mInstanceSize;
|
||||
private boolean mIsSoftReference;
|
||||
Field[] mStaticFields;
|
||||
private final long mStaticFieldsOffset;
|
||||
Set<ClassObj> mSubclasses;
|
||||
long mSuperClassId;
|
||||
|
||||
public static class HeapData {
|
||||
public int mShallowSize = 0;
|
||||
public List<Instance> mInstances = new ArrayList();
|
||||
}
|
||||
|
||||
public ClassObj(long j, StackTrace stackTrace, String str, long j2) {
|
||||
super(j, stackTrace);
|
||||
this.mIsSoftReference = false;
|
||||
this.mHeapData = new TIntObjectHashMap<>();
|
||||
this.mSubclasses = new HashSet();
|
||||
this.mClassName = str;
|
||||
this.mStaticFieldsOffset = j2;
|
||||
}
|
||||
|
||||
public static String getReferenceClassName() {
|
||||
return "java.lang.ref.Reference";
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.perflib.Instance
|
||||
public final void accept(Visitor visitor) {
|
||||
visitor.visitClassObj(this);
|
||||
for (Map.Entry<Field, Object> entry : getStaticFieldValues().entrySet()) {
|
||||
Object value = entry.getValue();
|
||||
if (value instanceof Instance) {
|
||||
if (!this.mReferencesAdded) {
|
||||
((Instance) value).addReference(entry.getKey(), this);
|
||||
}
|
||||
visitor.visitLater(this, (Instance) value);
|
||||
}
|
||||
}
|
||||
this.mReferencesAdded = true;
|
||||
}
|
||||
|
||||
public final void addInstance(int i, Instance instance) {
|
||||
if (instance instanceof ClassInstance) {
|
||||
instance.setSize(this.mInstanceSize);
|
||||
}
|
||||
HeapData heapData = this.mHeapData.get(i);
|
||||
if (heapData == null) {
|
||||
heapData = new HeapData();
|
||||
this.mHeapData.put(i, heapData);
|
||||
}
|
||||
heapData.mInstances.add(instance);
|
||||
heapData.mShallowSize += instance.getSize();
|
||||
}
|
||||
|
||||
public final void addSubclass(ClassObj classObj) {
|
||||
this.mSubclasses.add(classObj);
|
||||
}
|
||||
|
||||
public final void dump() {
|
||||
ClassObj classObj = this;
|
||||
while (true) {
|
||||
System.out.println("+---------- ClassObj dump for: " + classObj.mClassName);
|
||||
System.out.println("+----- Static fields");
|
||||
Map<Field, Object> staticFieldValues = classObj.getStaticFieldValues();
|
||||
for (Field field : staticFieldValues.keySet()) {
|
||||
System.out.println(field.getName() + ": " + field.getType() + " = " + staticFieldValues.get(field));
|
||||
}
|
||||
System.out.println("+----- Instance fields");
|
||||
for (Field field2 : classObj.mFields) {
|
||||
System.out.println(field2.getName() + ": " + field2.getType());
|
||||
}
|
||||
if (classObj.getSuperClassObj() == null) {
|
||||
return;
|
||||
} else {
|
||||
classObj = classObj.getSuperClassObj();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final void dumpSubclasses() {
|
||||
for (ClassObj classObj : this.mSubclasses) {
|
||||
System.out.println(" " + classObj.mClassName);
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean equals(Object obj) {
|
||||
return (obj instanceof ClassObj) && compareTo((ClassObj) obj) == 0;
|
||||
}
|
||||
|
||||
public int getAllFieldsCount() {
|
||||
int i = 0;
|
||||
for (ClassObj classObj = this; classObj != null; classObj = classObj.getSuperClassObj()) {
|
||||
i += classObj.getFields().length;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public Instance getClassLoader() {
|
||||
return this.mHeap.mSnapshot.findInstance(this.mClassLoaderId);
|
||||
}
|
||||
|
||||
public final String getClassName() {
|
||||
return this.mClassName;
|
||||
}
|
||||
|
||||
public List<ClassObj> getDescendantClasses() {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
Stack stack = new Stack();
|
||||
stack.push(this);
|
||||
while (!stack.isEmpty()) {
|
||||
ClassObj classObj = (ClassObj) stack.pop();
|
||||
arrayList.add(classObj);
|
||||
Iterator<ClassObj> it = classObj.getSubclasses().iterator();
|
||||
while (it.hasNext()) {
|
||||
stack.push(it.next());
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public Field[] getFields() {
|
||||
return this.mFields;
|
||||
}
|
||||
|
||||
public List<Instance> getHeapInstances(int i) {
|
||||
HeapData heapData = this.mHeapData.get(i);
|
||||
return heapData == null ? new ArrayList(0) : heapData.mInstances;
|
||||
}
|
||||
|
||||
public int getHeapInstancesCount(int i) {
|
||||
HeapData heapData = this.mHeapData.get(i);
|
||||
if (heapData == null) {
|
||||
return 0;
|
||||
}
|
||||
return heapData.mInstances.size();
|
||||
}
|
||||
|
||||
public int getInstanceCount() {
|
||||
int i = 0;
|
||||
for (Object obj : this.mHeapData.getValues()) {
|
||||
i += ((HeapData) obj).mInstances.size();
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public int getInstanceSize() {
|
||||
return this.mInstanceSize;
|
||||
}
|
||||
|
||||
public List<Instance> getInstancesList() {
|
||||
ArrayList arrayList = new ArrayList(getInstanceCount());
|
||||
for (int i : this.mHeapData.keys()) {
|
||||
arrayList.addAll(getHeapInstances(i));
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.perflib.Instance
|
||||
public boolean getIsSoftReference() {
|
||||
return this.mIsSoftReference;
|
||||
}
|
||||
|
||||
public int getShallowSize(int i) {
|
||||
if (this.mHeapData.get(i) == null) {
|
||||
return 0;
|
||||
}
|
||||
return this.mHeapData.get(i).mShallowSize;
|
||||
}
|
||||
|
||||
Object getStaticField(Type type, String str) {
|
||||
return getStaticFieldValues().get(new Field(type, str));
|
||||
}
|
||||
|
||||
public Map<Field, Object> getStaticFieldValues() {
|
||||
HashMap hashMap = new HashMap();
|
||||
getBuffer().setPosition(this.mStaticFieldsOffset);
|
||||
int readUnsignedShort = readUnsignedShort();
|
||||
for (int i = 0; i < readUnsignedShort; i++) {
|
||||
Field field = this.mStaticFields[i];
|
||||
readId();
|
||||
readUnsignedByte();
|
||||
hashMap.put(field, readValue(field.getType()));
|
||||
}
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
public final Set<ClassObj> getSubclasses() {
|
||||
return this.mSubclasses;
|
||||
}
|
||||
|
||||
public ClassObj getSuperClassObj() {
|
||||
return this.mHeap.mSnapshot.findClass(this.mSuperClassId);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return this.mClassName.hashCode();
|
||||
}
|
||||
|
||||
public final void setClassLoaderId(long j) {
|
||||
this.mClassLoaderId = j;
|
||||
}
|
||||
|
||||
public void setFields(Field[] fieldArr) {
|
||||
this.mFields = fieldArr;
|
||||
}
|
||||
|
||||
public void setInstanceSize(int i) {
|
||||
this.mInstanceSize = i;
|
||||
}
|
||||
|
||||
public void setIsSoftReference() {
|
||||
this.mIsSoftReference = true;
|
||||
}
|
||||
|
||||
public void setStaticFields(Field[] fieldArr) {
|
||||
this.mStaticFields = fieldArr;
|
||||
}
|
||||
|
||||
public final void setSuperClassId(long j) {
|
||||
this.mSuperClassId = j;
|
||||
}
|
||||
|
||||
public final String toString() {
|
||||
return this.mClassName.replace('/', '.');
|
||||
}
|
||||
|
||||
@Override // java.lang.Comparable
|
||||
public final int compareTo(ClassObj classObj) {
|
||||
if (getId() == classObj.getId()) {
|
||||
return 0;
|
||||
}
|
||||
int compareTo = this.mClassName.compareTo(classObj.mClassName);
|
||||
return compareTo != 0 ? compareTo : getId() - classObj.getId() > 0 ? 1 : -1;
|
||||
}
|
||||
|
||||
public int getShallowSize() {
|
||||
int i = 0;
|
||||
for (Object obj : this.mHeapData.getValues()) {
|
||||
i += ((HeapData) obj).mShallowSize;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
}
|
37
sources/com/squareup/haha/perflib/Field.java
Normal file
37
sources/com/squareup/haha/perflib/Field.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package com.squareup.haha.perflib;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class Field {
|
||||
private final String mName;
|
||||
private final Type mType;
|
||||
|
||||
public Field(Type type, String str) {
|
||||
this.mType = type;
|
||||
this.mName = str;
|
||||
}
|
||||
|
||||
public final boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof Field)) {
|
||||
return false;
|
||||
}
|
||||
Field field = (Field) obj;
|
||||
return this.mType == field.mType && this.mName.equals(field.mName);
|
||||
}
|
||||
|
||||
public final String getName() {
|
||||
return this.mName;
|
||||
}
|
||||
|
||||
public final Type getType() {
|
||||
return this.mType;
|
||||
}
|
||||
|
||||
public final int hashCode() {
|
||||
return Arrays.hashCode(new Object[]{this.mType, this.mName});
|
||||
}
|
||||
}
|
26
sources/com/squareup/haha/perflib/HahaSpy.java
Normal file
26
sources/com/squareup/haha/perflib/HahaSpy.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.squareup.haha.perflib;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class HahaSpy {
|
||||
private HahaSpy() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
public static Set<RootObj> allGcRoots(Snapshot snapshot) {
|
||||
HashSet hashSet = new HashSet();
|
||||
Iterator<Heap> it = snapshot.getHeaps().iterator();
|
||||
while (it.hasNext()) {
|
||||
hashSet.addAll(it.next().mRoots);
|
||||
}
|
||||
return hashSet;
|
||||
}
|
||||
|
||||
public static Instance allocatingThread(Instance instance) {
|
||||
Snapshot snapshot = instance.mHeap.mSnapshot;
|
||||
return snapshot.findInstance(snapshot.getThread(instance instanceof RootObj ? ((RootObj) instance).mThread : instance.mStack.mThreadSerialNumber).mId);
|
||||
}
|
||||
}
|
154
sources/com/squareup/haha/perflib/Heap.java
Normal file
154
sources/com/squareup/haha/perflib/Heap.java
Normal file
@@ -0,0 +1,154 @@
|
||||
package com.squareup.haha.perflib;
|
||||
|
||||
import com.squareup.haha.guava.collect.ArrayListMultimap;
|
||||
import com.squareup.haha.guava.collect.Multimap;
|
||||
import gnu.trove.TIntObjectHashMap;
|
||||
import gnu.trove.TLongObjectHashMap;
|
||||
import gnu.trove.TObjectProcedure;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Heap {
|
||||
private final int mId;
|
||||
private final String mName;
|
||||
Snapshot mSnapshot;
|
||||
TLongObjectHashMap<StackFrame> mFrames = new TLongObjectHashMap<>();
|
||||
TIntObjectHashMap<StackTrace> mTraces = new TIntObjectHashMap<>();
|
||||
ArrayList<RootObj> mRoots = new ArrayList<>();
|
||||
TIntObjectHashMap<ThreadObj> mThreads = new TIntObjectHashMap<>();
|
||||
TLongObjectHashMap<ClassObj> mClassesById = new TLongObjectHashMap<>();
|
||||
Multimap<String, ClassObj> mClassesByName = ArrayListMultimap.create();
|
||||
private final TLongObjectHashMap<Instance> mInstances = new TLongObjectHashMap<>();
|
||||
|
||||
public Heap(int i, String str) {
|
||||
this.mId = i;
|
||||
this.mName = str;
|
||||
}
|
||||
|
||||
public final void addClass(long j, ClassObj classObj) {
|
||||
this.mClassesById.put(j, classObj);
|
||||
this.mClassesByName.put(classObj.mClassName, classObj);
|
||||
}
|
||||
|
||||
public final void addInstance(long j, Instance instance) {
|
||||
this.mInstances.put(j, instance);
|
||||
}
|
||||
|
||||
public final void addRoot(RootObj rootObj) {
|
||||
rootObj.mIndex = this.mRoots.size();
|
||||
this.mRoots.add(rootObj);
|
||||
}
|
||||
|
||||
public final void addStackFrame(StackFrame stackFrame) {
|
||||
this.mFrames.put(stackFrame.mId, stackFrame);
|
||||
}
|
||||
|
||||
public final void addStackTrace(StackTrace stackTrace) {
|
||||
this.mTraces.put(stackTrace.mSerialNumber, stackTrace);
|
||||
}
|
||||
|
||||
public final void addThread(ThreadObj threadObj, int i) {
|
||||
this.mThreads.put(i, threadObj);
|
||||
}
|
||||
|
||||
public final void dumpInstanceCounts() {
|
||||
for (Object obj : this.mClassesById.getValues()) {
|
||||
ClassObj classObj = (ClassObj) obj;
|
||||
int instanceCount = classObj.getInstanceCount();
|
||||
if (instanceCount > 0) {
|
||||
System.out.println(classObj + ": " + instanceCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final void dumpSizes() {
|
||||
for (Object obj : this.mClassesById.getValues()) {
|
||||
ClassObj classObj = (ClassObj) obj;
|
||||
Iterator<Instance> it = classObj.getHeapInstances(getId()).iterator();
|
||||
int i = 0;
|
||||
while (it.hasNext()) {
|
||||
i += it.next().getCompositeSize();
|
||||
}
|
||||
if (i > 0) {
|
||||
System.out.println(classObj + ": base " + classObj.getSize() + ", composite " + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final void dumpSubclasses() {
|
||||
for (Object obj : this.mClassesById.getValues()) {
|
||||
ClassObj classObj = (ClassObj) obj;
|
||||
if (classObj.mSubclasses.size() > 0) {
|
||||
System.out.println(classObj);
|
||||
classObj.dumpSubclasses();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final ClassObj getClass(long j) {
|
||||
return this.mClassesById.get(j);
|
||||
}
|
||||
|
||||
public final Collection<ClassObj> getClasses(String str) {
|
||||
return this.mClassesByName.get(str);
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.mId;
|
||||
}
|
||||
|
||||
public final Instance getInstance(long j) {
|
||||
return this.mInstances.get(j);
|
||||
}
|
||||
|
||||
public Collection<Instance> getInstances() {
|
||||
final ArrayList arrayList = new ArrayList(this.mInstances.size());
|
||||
this.mInstances.forEachValue(new TObjectProcedure<Instance>() { // from class: com.squareup.haha.perflib.Heap.1
|
||||
@Override // gnu.trove.TObjectProcedure
|
||||
public boolean execute(Instance instance) {
|
||||
arrayList.add(instance);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public int getInstancesCount() {
|
||||
return this.mInstances.size();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.mName;
|
||||
}
|
||||
|
||||
public final StackFrame getStackFrame(long j) {
|
||||
return this.mFrames.get(j);
|
||||
}
|
||||
|
||||
public final StackTrace getStackTrace(int i) {
|
||||
return this.mTraces.get(i);
|
||||
}
|
||||
|
||||
public final StackTrace getStackTraceAtDepth(int i, int i2) {
|
||||
StackTrace stackTrace = this.mTraces.get(i);
|
||||
return stackTrace != null ? stackTrace.fromDepth(i2) : stackTrace;
|
||||
}
|
||||
|
||||
public final ThreadObj getThread(int i) {
|
||||
return this.mThreads.get(i);
|
||||
}
|
||||
|
||||
public final ClassObj getClass(String str) {
|
||||
Collection<ClassObj> collection = this.mClassesByName.get(str);
|
||||
if (collection.size() == 1) {
|
||||
return collection.iterator().next();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Collection<ClassObj> getClasses() {
|
||||
return this.mClassesByName.values();
|
||||
}
|
||||
}
|
402
sources/com/squareup/haha/perflib/HprofParser.java
Normal file
402
sources/com/squareup/haha/perflib/HprofParser.java
Normal file
@@ -0,0 +1,402 @@
|
||||
package com.squareup.haha.perflib;
|
||||
|
||||
import com.squareup.haha.perflib.io.HprofBuffer;
|
||||
import gnu.trove.TLongObjectHashMap;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class HprofParser {
|
||||
private static final int ALLOC_SITES = 6;
|
||||
private static final int CONTROL_SETTINGS = 14;
|
||||
private static final int CPU_SAMPLES = 13;
|
||||
private static final int END_THREAD = 11;
|
||||
private static final int HEAP_DUMP = 12;
|
||||
private static final int HEAP_DUMP_END = 44;
|
||||
private static final int HEAP_DUMP_SEGMENT = 28;
|
||||
private static final int HEAP_SUMMARY = 7;
|
||||
private static final int LOAD_CLASS = 2;
|
||||
private static final int ROOT_CLASS_DUMP = 32;
|
||||
private static final int ROOT_DEBUGGER = 139;
|
||||
private static final int ROOT_FINALIZING = 138;
|
||||
private static final int ROOT_HEAP_DUMP_INFO = 254;
|
||||
private static final int ROOT_INSTANCE_DUMP = 33;
|
||||
private static final int ROOT_INTERNED_STRING = 137;
|
||||
private static final int ROOT_JAVA_FRAME = 3;
|
||||
private static final int ROOT_JNI_GLOBAL = 1;
|
||||
private static final int ROOT_JNI_LOCAL = 2;
|
||||
private static final int ROOT_JNI_MONITOR = 142;
|
||||
private static final int ROOT_MONITOR_USED = 7;
|
||||
private static final int ROOT_NATIVE_STACK = 4;
|
||||
private static final int ROOT_OBJECT_ARRAY_DUMP = 34;
|
||||
private static final int ROOT_PRIMITIVE_ARRAY_DUMP = 35;
|
||||
private static final int ROOT_PRIMITIVE_ARRAY_NODATA = 195;
|
||||
private static final int ROOT_REFERENCE_CLEANUP = 140;
|
||||
private static final int ROOT_STICKY_CLASS = 5;
|
||||
private static final int ROOT_THREAD_BLOCK = 6;
|
||||
private static final int ROOT_THREAD_OBJECT = 8;
|
||||
private static final int ROOT_UNKNOWN = 255;
|
||||
private static final int ROOT_UNREACHABLE = 144;
|
||||
private static final int ROOT_VM_INTERNAL = 141;
|
||||
private static final int STACK_FRAME = 4;
|
||||
private static final int STACK_TRACE = 5;
|
||||
private static final int START_THREAD = 10;
|
||||
private static final int STRING_IN_UTF8 = 1;
|
||||
private static final int UNLOAD_CLASS = 3;
|
||||
int mIdSize;
|
||||
private final HprofBuffer mInput;
|
||||
Snapshot mSnapshot;
|
||||
TLongObjectHashMap<String> mStrings = new TLongObjectHashMap<>();
|
||||
TLongObjectHashMap<String> mClassNames = new TLongObjectHashMap<>();
|
||||
|
||||
public HprofParser(HprofBuffer hprofBuffer) {
|
||||
this.mInput = hprofBuffer;
|
||||
}
|
||||
|
||||
private int loadBasicObj(RootType rootType) throws IOException {
|
||||
this.mSnapshot.addRoot(new RootObj(rootType, readId()));
|
||||
return this.mIdSize;
|
||||
}
|
||||
|
||||
private void loadClass() throws IOException {
|
||||
this.mInput.readInt();
|
||||
long readId = readId();
|
||||
this.mInput.readInt();
|
||||
this.mClassNames.put(readId, this.mStrings.get(readId()));
|
||||
}
|
||||
|
||||
private int loadClassDump() throws IOException {
|
||||
long readId = readId();
|
||||
StackTrace stackTrace = this.mSnapshot.getStackTrace(this.mInput.readInt());
|
||||
long readId2 = readId();
|
||||
long readId3 = readId();
|
||||
readId();
|
||||
readId();
|
||||
readId();
|
||||
readId();
|
||||
int readInt = this.mInput.readInt();
|
||||
int i = (this.mIdSize * 7) + 4 + 4;
|
||||
int readUnsignedShort = readUnsignedShort();
|
||||
int i2 = i + 2;
|
||||
for (int i3 = 0; i3 < readUnsignedShort; i3++) {
|
||||
readUnsignedShort();
|
||||
i2 += skipValue() + 2;
|
||||
}
|
||||
ClassObj classObj = new ClassObj(readId, stackTrace, this.mClassNames.get(readId), this.mInput.position());
|
||||
classObj.setSuperClassId(readId2);
|
||||
classObj.setClassLoaderId(readId3);
|
||||
int readUnsignedShort2 = readUnsignedShort();
|
||||
int i4 = i2 + 2;
|
||||
Field[] fieldArr = new Field[readUnsignedShort2];
|
||||
for (int i5 = 0; i5 < readUnsignedShort2; i5++) {
|
||||
String str = this.mStrings.get(readId());
|
||||
Type type = Type.getType(this.mInput.readByte());
|
||||
fieldArr[i5] = new Field(type, str);
|
||||
skipFully(this.mSnapshot.getTypeSize(type));
|
||||
i4 += this.mIdSize + 1 + this.mSnapshot.getTypeSize(type);
|
||||
}
|
||||
classObj.setStaticFields(fieldArr);
|
||||
int readUnsignedShort3 = readUnsignedShort();
|
||||
int i6 = i4 + 2;
|
||||
Field[] fieldArr2 = new Field[readUnsignedShort3];
|
||||
for (int i7 = 0; i7 < readUnsignedShort3; i7++) {
|
||||
fieldArr2[i7] = new Field(Type.getType(readUnsignedByte()), this.mStrings.get(readId()));
|
||||
i6 += this.mIdSize + 1;
|
||||
}
|
||||
classObj.setFields(fieldArr2);
|
||||
classObj.setInstanceSize(readInt);
|
||||
this.mSnapshot.addClass(readId, classObj);
|
||||
return i6;
|
||||
}
|
||||
|
||||
private void loadHeapDump(long j) throws IOException {
|
||||
int loadBasicObj;
|
||||
while (j > 0) {
|
||||
int readUnsignedByte = readUnsignedByte();
|
||||
long j2 = j - 1;
|
||||
if (readUnsignedByte == ROOT_UNREACHABLE) {
|
||||
loadBasicObj = loadBasicObj(RootType.UNREACHABLE);
|
||||
} else {
|
||||
if (readUnsignedByte == ROOT_PRIMITIVE_ARRAY_NODATA) {
|
||||
System.err.println("+--- PRIMITIVE ARRAY NODATA DUMP");
|
||||
loadPrimitiveArrayDump();
|
||||
throw new IllegalArgumentException("Don't know how to load a nodata array");
|
||||
}
|
||||
if (readUnsignedByte == ROOT_HEAP_DUMP_INFO) {
|
||||
this.mSnapshot.setHeapTo(this.mInput.readInt(), this.mStrings.get(readId()));
|
||||
loadBasicObj = this.mIdSize + 4;
|
||||
} else if (readUnsignedByte != ROOT_UNKNOWN) {
|
||||
switch (readUnsignedByte) {
|
||||
case 1:
|
||||
j2 -= loadBasicObj(RootType.NATIVE_STATIC);
|
||||
readId();
|
||||
loadBasicObj = this.mIdSize;
|
||||
break;
|
||||
case 2:
|
||||
loadBasicObj = loadJniLocal();
|
||||
break;
|
||||
case 3:
|
||||
loadBasicObj = loadJavaFrame();
|
||||
break;
|
||||
case 4:
|
||||
loadBasicObj = loadNativeStack();
|
||||
break;
|
||||
case 5:
|
||||
loadBasicObj = loadBasicObj(RootType.SYSTEM_CLASS);
|
||||
break;
|
||||
case 6:
|
||||
loadBasicObj = loadThreadBlock();
|
||||
break;
|
||||
case 7:
|
||||
loadBasicObj = loadBasicObj(RootType.BUSY_MONITOR);
|
||||
break;
|
||||
case 8:
|
||||
loadBasicObj = loadThreadObject();
|
||||
break;
|
||||
default:
|
||||
switch (readUnsignedByte) {
|
||||
case 32:
|
||||
loadBasicObj = loadClassDump();
|
||||
break;
|
||||
case 33:
|
||||
loadBasicObj = loadInstanceDump();
|
||||
break;
|
||||
case 34:
|
||||
loadBasicObj = loadObjectArrayDump();
|
||||
break;
|
||||
case 35:
|
||||
loadBasicObj = loadPrimitiveArrayDump();
|
||||
break;
|
||||
default:
|
||||
switch (readUnsignedByte) {
|
||||
case ROOT_INTERNED_STRING /* 137 */:
|
||||
loadBasicObj = loadBasicObj(RootType.INTERNED_STRING);
|
||||
break;
|
||||
case ROOT_FINALIZING /* 138 */:
|
||||
loadBasicObj = loadBasicObj(RootType.FINALIZING);
|
||||
break;
|
||||
case ROOT_DEBUGGER /* 139 */:
|
||||
loadBasicObj = loadBasicObj(RootType.DEBUGGER);
|
||||
break;
|
||||
case 140:
|
||||
loadBasicObj = loadBasicObj(RootType.REFERENCE_CLEANUP);
|
||||
break;
|
||||
case ROOT_VM_INTERNAL /* 141 */:
|
||||
loadBasicObj = loadBasicObj(RootType.VM_INTERNAL);
|
||||
break;
|
||||
case ROOT_JNI_MONITOR /* 142 */:
|
||||
loadBasicObj = loadJniMonitor();
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("loadHeapDump loop with unknown tag " + readUnsignedByte + " with " + this.mInput.remaining() + " bytes possibly remaining");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
loadBasicObj = loadBasicObj(RootType.UNKNOWN);
|
||||
}
|
||||
}
|
||||
j = j2 - loadBasicObj;
|
||||
}
|
||||
}
|
||||
|
||||
private int loadInstanceDump() throws IOException {
|
||||
long readId = readId();
|
||||
StackTrace stackTrace = this.mSnapshot.getStackTrace(this.mInput.readInt());
|
||||
long readId2 = readId();
|
||||
int readInt = this.mInput.readInt();
|
||||
ClassInstance classInstance = new ClassInstance(readId, stackTrace, this.mInput.position());
|
||||
classInstance.setClassId(readId2);
|
||||
this.mSnapshot.addInstance(readId, classInstance);
|
||||
skipFully(readInt);
|
||||
int i = this.mIdSize;
|
||||
return i + 4 + i + 4 + readInt;
|
||||
}
|
||||
|
||||
private int loadJavaFrame() throws IOException {
|
||||
long readId = readId();
|
||||
int readInt = this.mInput.readInt();
|
||||
this.mSnapshot.addRoot(new RootObj(RootType.JAVA_LOCAL, readId, readInt, this.mSnapshot.getStackTraceAtDepth(this.mSnapshot.getThread(readInt).mStackTrace, this.mInput.readInt())));
|
||||
return this.mIdSize + 4 + 4;
|
||||
}
|
||||
|
||||
private int loadJniLocal() throws IOException {
|
||||
long readId = readId();
|
||||
int readInt = this.mInput.readInt();
|
||||
this.mSnapshot.addRoot(new RootObj(RootType.NATIVE_LOCAL, readId, readInt, this.mSnapshot.getStackTraceAtDepth(this.mSnapshot.getThread(readInt).mStackTrace, this.mInput.readInt())));
|
||||
return this.mIdSize + 4 + 4;
|
||||
}
|
||||
|
||||
private int loadJniMonitor() throws IOException {
|
||||
long readId = readId();
|
||||
int readInt = this.mInput.readInt();
|
||||
this.mSnapshot.addRoot(new RootObj(RootType.NATIVE_MONITOR, readId, readInt, this.mSnapshot.getStackTraceAtDepth(this.mSnapshot.getThread(readInt).mStackTrace, this.mInput.readInt())));
|
||||
return this.mIdSize + 4 + 4;
|
||||
}
|
||||
|
||||
private int loadNativeStack() throws IOException {
|
||||
long readId = readId();
|
||||
int readInt = this.mInput.readInt();
|
||||
this.mSnapshot.addRoot(new RootObj(RootType.NATIVE_STACK, readId, readInt, this.mSnapshot.getStackTrace(this.mSnapshot.getThread(readInt).mStackTrace)));
|
||||
return this.mIdSize + 4;
|
||||
}
|
||||
|
||||
private int loadObjectArrayDump() throws IOException {
|
||||
long readId = readId();
|
||||
StackTrace stackTrace = this.mSnapshot.getStackTrace(this.mInput.readInt());
|
||||
int readInt = this.mInput.readInt();
|
||||
long readId2 = readId();
|
||||
ArrayInstance arrayInstance = new ArrayInstance(readId, stackTrace, Type.OBJECT, readInt, this.mInput.position());
|
||||
arrayInstance.setClassId(readId2);
|
||||
this.mSnapshot.addInstance(readId, arrayInstance);
|
||||
int i = readInt * this.mIdSize;
|
||||
skipFully(i);
|
||||
int i2 = this.mIdSize;
|
||||
return i2 + 4 + 4 + i2 + i;
|
||||
}
|
||||
|
||||
private int loadPrimitiveArrayDump() throws IOException {
|
||||
long readId = readId();
|
||||
StackTrace stackTrace = this.mSnapshot.getStackTrace(this.mInput.readInt());
|
||||
int readInt = this.mInput.readInt();
|
||||
Type type = Type.getType(readUnsignedByte());
|
||||
int typeSize = this.mSnapshot.getTypeSize(type);
|
||||
this.mSnapshot.addInstance(readId, new ArrayInstance(readId, stackTrace, type, readInt, this.mInput.position()));
|
||||
int i = readInt * typeSize;
|
||||
skipFully(i);
|
||||
return this.mIdSize + 4 + 4 + 1 + i;
|
||||
}
|
||||
|
||||
private void loadStackFrame() throws IOException {
|
||||
this.mSnapshot.addStackFrame(new StackFrame(readId(), this.mStrings.get(readId()), this.mStrings.get(readId()), this.mStrings.get(readId()), this.mInput.readInt(), this.mInput.readInt()));
|
||||
}
|
||||
|
||||
private void loadStackTrace() throws IOException {
|
||||
int readInt = this.mInput.readInt();
|
||||
int readInt2 = this.mInput.readInt();
|
||||
int readInt3 = this.mInput.readInt();
|
||||
StackFrame[] stackFrameArr = new StackFrame[readInt3];
|
||||
for (int i = 0; i < readInt3; i++) {
|
||||
stackFrameArr[i] = this.mSnapshot.getStackFrame(readId());
|
||||
}
|
||||
this.mSnapshot.addStackTrace(new StackTrace(readInt, readInt2, stackFrameArr));
|
||||
}
|
||||
|
||||
private void loadString(int i) throws IOException {
|
||||
this.mStrings.put(readId(), readUTF8(i));
|
||||
}
|
||||
|
||||
private int loadThreadBlock() throws IOException {
|
||||
long readId = readId();
|
||||
int readInt = this.mInput.readInt();
|
||||
this.mSnapshot.addRoot(new RootObj(RootType.THREAD_BLOCK, readId, readInt, this.mSnapshot.getStackTrace(this.mSnapshot.getThread(readInt).mStackTrace)));
|
||||
return this.mIdSize + 4;
|
||||
}
|
||||
|
||||
private int loadThreadObject() throws IOException {
|
||||
long readId = readId();
|
||||
int readInt = this.mInput.readInt();
|
||||
this.mSnapshot.addThread(new ThreadObj(readId, this.mInput.readInt()), readInt);
|
||||
return this.mIdSize + 4 + 4;
|
||||
}
|
||||
|
||||
private long readId() throws IOException {
|
||||
int i = this.mIdSize;
|
||||
if (i == 1) {
|
||||
return this.mInput.readByte();
|
||||
}
|
||||
if (i == 2) {
|
||||
return this.mInput.readShort();
|
||||
}
|
||||
if (i == 4) {
|
||||
return this.mInput.readInt();
|
||||
}
|
||||
if (i == 8) {
|
||||
return this.mInput.readLong();
|
||||
}
|
||||
throw new IllegalArgumentException("ID Length must be 1, 2, 4, or 8");
|
||||
}
|
||||
|
||||
private String readNullTerminatedString() throws IOException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while (true) {
|
||||
byte readByte = this.mInput.readByte();
|
||||
if (readByte == 0) {
|
||||
return sb.toString();
|
||||
}
|
||||
sb.append((char) readByte);
|
||||
}
|
||||
}
|
||||
|
||||
private String readUTF8(int i) throws IOException {
|
||||
byte[] bArr = new byte[i];
|
||||
this.mInput.read(bArr);
|
||||
return new String(bArr, "utf-8");
|
||||
}
|
||||
|
||||
private int readUnsignedByte() throws IOException {
|
||||
return this.mInput.readByte() & 255;
|
||||
}
|
||||
|
||||
private long readUnsignedInt() throws IOException {
|
||||
return this.mInput.readInt() & 4294967295L;
|
||||
}
|
||||
|
||||
private int readUnsignedShort() throws IOException {
|
||||
return this.mInput.readShort() & 65535;
|
||||
}
|
||||
|
||||
private void skipFully(long j) throws IOException {
|
||||
HprofBuffer hprofBuffer = this.mInput;
|
||||
hprofBuffer.setPosition(hprofBuffer.position() + j);
|
||||
}
|
||||
|
||||
private int skipValue() throws IOException {
|
||||
int typeSize = this.mSnapshot.getTypeSize(Type.getType(readUnsignedByte()));
|
||||
skipFully(typeSize);
|
||||
return typeSize + 1;
|
||||
}
|
||||
|
||||
public final Snapshot parse() {
|
||||
Snapshot snapshot = new Snapshot(this.mInput);
|
||||
this.mSnapshot = snapshot;
|
||||
try {
|
||||
try {
|
||||
readNullTerminatedString();
|
||||
this.mIdSize = this.mInput.readInt();
|
||||
this.mSnapshot.setIdSize(this.mIdSize);
|
||||
this.mInput.readLong();
|
||||
while (this.mInput.hasRemaining()) {
|
||||
int readUnsignedByte = readUnsignedByte();
|
||||
this.mInput.readInt();
|
||||
long readUnsignedInt = readUnsignedInt();
|
||||
if (readUnsignedByte == 1) {
|
||||
loadString(((int) readUnsignedInt) - this.mIdSize);
|
||||
} else if (readUnsignedByte == 2) {
|
||||
loadClass();
|
||||
} else if (readUnsignedByte == 4) {
|
||||
loadStackFrame();
|
||||
} else if (readUnsignedByte == 5) {
|
||||
loadStackTrace();
|
||||
} else if (readUnsignedByte == 12) {
|
||||
loadHeapDump(readUnsignedInt);
|
||||
this.mSnapshot.setToDefaultHeap();
|
||||
} else if (readUnsignedByte != 28) {
|
||||
skipFully(readUnsignedInt);
|
||||
} else {
|
||||
loadHeapDump(readUnsignedInt);
|
||||
this.mSnapshot.setToDefaultHeap();
|
||||
}
|
||||
}
|
||||
} catch (EOFException unused) {
|
||||
}
|
||||
this.mSnapshot.resolveClasses();
|
||||
this.mSnapshot.resolveReferences();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.mClassNames.clear();
|
||||
this.mStrings.clear();
|
||||
return snapshot;
|
||||
}
|
||||
}
|
267
sources/com/squareup/haha/perflib/Instance.java
Normal file
267
sources/com/squareup/haha/perflib/Instance.java
Normal file
@@ -0,0 +1,267 @@
|
||||
package com.squareup.haha.perflib;
|
||||
|
||||
import com.squareup.haha.guava.collect.ImmutableList;
|
||||
import com.squareup.haha.perflib.io.HprofBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class Instance {
|
||||
static final /* synthetic */ boolean $assertionsDisabled = false;
|
||||
long mClassId;
|
||||
Heap mHeap;
|
||||
protected final long mId;
|
||||
private Instance mImmediateDominator;
|
||||
private long[] mRetainedSizes;
|
||||
int mSize;
|
||||
protected final StackTrace mStack;
|
||||
int mTopologicalOrder;
|
||||
int mDistanceToGcRoot = Integer.MAX_VALUE;
|
||||
boolean mReferencesAdded = false;
|
||||
Instance mNextInstanceToGcRoot = null;
|
||||
private final ArrayList<Instance> mHardReferences = new ArrayList<>();
|
||||
private ArrayList<Instance> mSoftReferences = null;
|
||||
|
||||
/* renamed from: com.squareup.haha.perflib.Instance$1, reason: invalid class name */
|
||||
static /* synthetic */ class AnonymousClass1 {
|
||||
static final /* synthetic */ int[] $SwitchMap$com$android$tools$perflib$heap$Type = new int[Type.values().length];
|
||||
|
||||
static {
|
||||
try {
|
||||
$SwitchMap$com$android$tools$perflib$heap$Type[Type.OBJECT.ordinal()] = 1;
|
||||
} catch (NoSuchFieldError unused) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$android$tools$perflib$heap$Type[Type.BOOLEAN.ordinal()] = 2;
|
||||
} catch (NoSuchFieldError unused2) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$android$tools$perflib$heap$Type[Type.CHAR.ordinal()] = 3;
|
||||
} catch (NoSuchFieldError unused3) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$android$tools$perflib$heap$Type[Type.FLOAT.ordinal()] = 4;
|
||||
} catch (NoSuchFieldError unused4) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$android$tools$perflib$heap$Type[Type.DOUBLE.ordinal()] = 5;
|
||||
} catch (NoSuchFieldError unused5) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$android$tools$perflib$heap$Type[Type.BYTE.ordinal()] = 6;
|
||||
} catch (NoSuchFieldError unused6) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$android$tools$perflib$heap$Type[Type.SHORT.ordinal()] = 7;
|
||||
} catch (NoSuchFieldError unused7) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$android$tools$perflib$heap$Type[Type.INT.ordinal()] = 8;
|
||||
} catch (NoSuchFieldError unused8) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$android$tools$perflib$heap$Type[Type.LONG.ordinal()] = 9;
|
||||
} catch (NoSuchFieldError unused9) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class CompositeSizeVisitor extends NonRecursiveVisitor {
|
||||
int mSize = 0;
|
||||
|
||||
@Override // com.squareup.haha.perflib.NonRecursiveVisitor
|
||||
protected void defaultAction(Instance instance) {
|
||||
this.mSize += instance.getSize();
|
||||
}
|
||||
|
||||
public int getCompositeSize() {
|
||||
return this.mSize;
|
||||
}
|
||||
}
|
||||
|
||||
Instance(long j, StackTrace stackTrace) {
|
||||
this.mId = j;
|
||||
this.mStack = stackTrace;
|
||||
}
|
||||
|
||||
public abstract void accept(Visitor visitor);
|
||||
|
||||
public void addReference(Field field, Instance instance) {
|
||||
if (!instance.getIsSoftReference() || field == null || !field.getName().equals("referent")) {
|
||||
this.mHardReferences.add(instance);
|
||||
return;
|
||||
}
|
||||
if (this.mSoftReferences == null) {
|
||||
this.mSoftReferences = new ArrayList<>();
|
||||
}
|
||||
this.mSoftReferences.add(instance);
|
||||
}
|
||||
|
||||
public void addRetainedSize(int i, long j) {
|
||||
long[] jArr = this.mRetainedSizes;
|
||||
jArr[i] = jArr[i] + j;
|
||||
}
|
||||
|
||||
protected HprofBuffer getBuffer() {
|
||||
return this.mHeap.mSnapshot.mBuffer;
|
||||
}
|
||||
|
||||
public ClassObj getClassObj() {
|
||||
return this.mHeap.mSnapshot.findClass(this.mClassId);
|
||||
}
|
||||
|
||||
public final int getCompositeSize() {
|
||||
CompositeSizeVisitor compositeSizeVisitor = new CompositeSizeVisitor();
|
||||
compositeSizeVisitor.doVisit(ImmutableList.of(this));
|
||||
return compositeSizeVisitor.getCompositeSize();
|
||||
}
|
||||
|
||||
public int getDistanceToGcRoot() {
|
||||
return this.mDistanceToGcRoot;
|
||||
}
|
||||
|
||||
public ArrayList<Instance> getHardReferences() {
|
||||
return this.mHardReferences;
|
||||
}
|
||||
|
||||
public Heap getHeap() {
|
||||
return this.mHeap;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return this.mId;
|
||||
}
|
||||
|
||||
public Instance getImmediateDominator() {
|
||||
return this.mImmediateDominator;
|
||||
}
|
||||
|
||||
public boolean getIsSoftReference() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Instance getNextInstanceToGcRoot() {
|
||||
return this.mNextInstanceToGcRoot;
|
||||
}
|
||||
|
||||
public long getRetainedSize(int i) {
|
||||
return this.mRetainedSizes[i];
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return this.mSize;
|
||||
}
|
||||
|
||||
public ArrayList<Instance> getSoftReferences() {
|
||||
return this.mSoftReferences;
|
||||
}
|
||||
|
||||
public int getTopologicalOrder() {
|
||||
return this.mTopologicalOrder;
|
||||
}
|
||||
|
||||
public long getTotalRetainedSize() {
|
||||
long[] jArr = this.mRetainedSizes;
|
||||
long j = 0;
|
||||
if (jArr == null) {
|
||||
return 0L;
|
||||
}
|
||||
for (long j2 : jArr) {
|
||||
j += j2;
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
public long getUniqueId() {
|
||||
return getId() & this.mHeap.mSnapshot.getIdSizeMask();
|
||||
}
|
||||
|
||||
protected long readId() {
|
||||
int typeSize = this.mHeap.mSnapshot.getTypeSize(Type.OBJECT);
|
||||
if (typeSize == 1) {
|
||||
return getBuffer().readByte();
|
||||
}
|
||||
if (typeSize == 2) {
|
||||
return getBuffer().readShort();
|
||||
}
|
||||
if (typeSize == 4) {
|
||||
return getBuffer().readInt();
|
||||
}
|
||||
if (typeSize != 8) {
|
||||
return 0L;
|
||||
}
|
||||
return getBuffer().readLong();
|
||||
}
|
||||
|
||||
protected int readUnsignedByte() {
|
||||
return getBuffer().readByte() & 255;
|
||||
}
|
||||
|
||||
protected int readUnsignedShort() {
|
||||
return getBuffer().readShort() & 65535;
|
||||
}
|
||||
|
||||
protected Object readValue(Type type) {
|
||||
switch (AnonymousClass1.$SwitchMap$com$android$tools$perflib$heap$Type[type.ordinal()]) {
|
||||
case 1:
|
||||
return this.mHeap.mSnapshot.findInstance(readId());
|
||||
case 2:
|
||||
return Boolean.valueOf(getBuffer().readByte() != 0);
|
||||
case 3:
|
||||
return Character.valueOf(getBuffer().readChar());
|
||||
case 4:
|
||||
return Float.valueOf(getBuffer().readFloat());
|
||||
case 5:
|
||||
return Double.valueOf(getBuffer().readDouble());
|
||||
case 6:
|
||||
return Byte.valueOf(getBuffer().readByte());
|
||||
case 7:
|
||||
return Short.valueOf(getBuffer().readShort());
|
||||
case 8:
|
||||
return Integer.valueOf(getBuffer().readInt());
|
||||
case 9:
|
||||
return Long.valueOf(getBuffer().readLong());
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void resetRetainedSize() {
|
||||
ArrayList<Heap> arrayList = this.mHeap.mSnapshot.mHeaps;
|
||||
long[] jArr = this.mRetainedSizes;
|
||||
if (jArr == null) {
|
||||
this.mRetainedSizes = new long[arrayList.size()];
|
||||
} else {
|
||||
Arrays.fill(jArr, 0L);
|
||||
}
|
||||
this.mRetainedSizes[arrayList.indexOf(this.mHeap)] = getSize();
|
||||
}
|
||||
|
||||
public void setClassId(long j) {
|
||||
this.mClassId = j;
|
||||
}
|
||||
|
||||
public void setDistanceToGcRoot(int i) {
|
||||
this.mDistanceToGcRoot = i;
|
||||
}
|
||||
|
||||
public void setHeap(Heap heap) {
|
||||
this.mHeap = heap;
|
||||
}
|
||||
|
||||
public void setImmediateDominator(Instance instance) {
|
||||
this.mImmediateDominator = instance;
|
||||
}
|
||||
|
||||
public void setNextInstanceToGcRoot(Instance instance) {
|
||||
this.mNextInstanceToGcRoot = instance;
|
||||
}
|
||||
|
||||
public void setSize(int i) {
|
||||
this.mSize = i;
|
||||
}
|
||||
|
||||
public void setTopologicalOrder(int i) {
|
||||
this.mTopologicalOrder = i;
|
||||
}
|
||||
}
|
54
sources/com/squareup/haha/perflib/Main.java
Normal file
54
sources/com/squareup/haha/perflib/Main.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package com.squareup.haha.perflib;
|
||||
|
||||
import com.squareup.haha.perflib.io.MemoryMappedFileBuffer;
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Main {
|
||||
public static void main(String[] strArr) {
|
||||
try {
|
||||
long nanoTime = System.nanoTime();
|
||||
Snapshot parse = new HprofParser(new MemoryMappedFileBuffer(new File(strArr[0]))).parse();
|
||||
testClassesQuery(parse);
|
||||
testAllClassesQuery(parse);
|
||||
testFindInstancesOf(parse);
|
||||
testFindAllInstancesOf(parse);
|
||||
System.out.println("Memory stats: free=" + Runtime.getRuntime().freeMemory() + " / total=" + Runtime.getRuntime().totalMemory());
|
||||
System.out.println("Time: " + ((System.nanoTime() - nanoTime) / 1000000) + "ms");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void testAllClassesQuery(Snapshot snapshot) {
|
||||
Map<String, Set<ClassObj>> allClasses = Queries.allClasses(snapshot);
|
||||
for (String str : allClasses.keySet()) {
|
||||
System.out.println("------------------- " + str);
|
||||
for (ClassObj classObj : allClasses.get(str)) {
|
||||
System.out.println(" " + classObj.mClassName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testClassesQuery(Snapshot snapshot) {
|
||||
Map<String, Set<ClassObj>> classes = Queries.classes(snapshot, new String[]{"char[", "javax.", "org.xml.sax"});
|
||||
for (String str : classes.keySet()) {
|
||||
System.out.println("------------------- " + str);
|
||||
for (ClassObj classObj : classes.get(str)) {
|
||||
System.out.println(" " + classObj.mClassName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testFindAllInstancesOf(Snapshot snapshot) {
|
||||
Instance[] allInstancesOf = Queries.allInstancesOf(snapshot, "android.graphics.drawable.Drawable");
|
||||
System.out.println("There are " + allInstancesOf.length + " instances of Drawables and its subclasses.");
|
||||
}
|
||||
|
||||
private static void testFindInstancesOf(Snapshot snapshot) {
|
||||
Instance[] instancesOf = Queries.instancesOf(snapshot, "java.lang.String");
|
||||
System.out.println("There are " + instancesOf.length + " Strings.");
|
||||
}
|
||||
}
|
55
sources/com/squareup/haha/perflib/NonRecursiveVisitor.java
Normal file
55
sources/com/squareup/haha/perflib/NonRecursiveVisitor.java
Normal file
@@ -0,0 +1,55 @@
|
||||
package com.squareup.haha.perflib;
|
||||
|
||||
import gnu.trove.TLongHashSet;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class NonRecursiveVisitor implements Visitor {
|
||||
public final Deque<Instance> mStack = new ArrayDeque();
|
||||
public final TLongHashSet mSeen = new TLongHashSet();
|
||||
|
||||
protected void defaultAction(Instance instance) {
|
||||
}
|
||||
|
||||
public void doVisit(Iterable<? extends Instance> iterable) {
|
||||
for (Instance instance : iterable) {
|
||||
if (instance instanceof RootObj) {
|
||||
instance.accept(this);
|
||||
} else {
|
||||
visitLater(null, instance);
|
||||
}
|
||||
}
|
||||
while (!this.mStack.isEmpty()) {
|
||||
Instance pop = this.mStack.pop();
|
||||
if (this.mSeen.add(pop.getId())) {
|
||||
pop.accept(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.perflib.Visitor
|
||||
public void visitArrayInstance(ArrayInstance arrayInstance) {
|
||||
defaultAction(arrayInstance);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.perflib.Visitor
|
||||
public void visitClassInstance(ClassInstance classInstance) {
|
||||
defaultAction(classInstance);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.perflib.Visitor
|
||||
public void visitClassObj(ClassObj classObj) {
|
||||
defaultAction(classObj);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.perflib.Visitor
|
||||
public void visitLater(Instance instance, Instance instance2) {
|
||||
this.mStack.push(instance2);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.perflib.Visitor
|
||||
public void visitRootObj(RootObj rootObj) {
|
||||
defaultAction(rootObj);
|
||||
}
|
||||
}
|
142
sources/com/squareup/haha/perflib/Queries.java
Normal file
142
sources/com/squareup/haha/perflib/Queries.java
Normal file
@@ -0,0 +1,142 @@
|
||||
package com.squareup.haha.perflib;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Queries {
|
||||
private static final String DEFAULT_PACKAGE = "<default>";
|
||||
|
||||
public static Map<String, Set<ClassObj>> allClasses(Snapshot snapshot) {
|
||||
return classes(snapshot, null);
|
||||
}
|
||||
|
||||
public static Instance[] allInstancesOf(Snapshot snapshot, String str) {
|
||||
ClassObj findClass = snapshot.findClass(str);
|
||||
if (findClass == null) {
|
||||
throw new IllegalArgumentException("Class not found: " + str);
|
||||
}
|
||||
ArrayList arrayList = new ArrayList();
|
||||
arrayList.add(findClass);
|
||||
arrayList.addAll(traverseSubclasses(findClass));
|
||||
ArrayList arrayList2 = new ArrayList();
|
||||
Iterator it = arrayList.iterator();
|
||||
while (it.hasNext()) {
|
||||
arrayList2.addAll(((ClassObj) it.next()).getInstancesList());
|
||||
}
|
||||
Instance[] instanceArr = new Instance[arrayList2.size()];
|
||||
arrayList2.toArray(instanceArr);
|
||||
return instanceArr;
|
||||
}
|
||||
|
||||
public static Map<String, Set<ClassObj>> classes(Snapshot snapshot, String[] strArr) {
|
||||
TreeMap treeMap = new TreeMap();
|
||||
TreeSet<ClassObj> treeSet = new TreeSet();
|
||||
Iterator<Heap> it = snapshot.mHeaps.iterator();
|
||||
while (it.hasNext()) {
|
||||
treeSet.addAll(it.next().getClasses());
|
||||
}
|
||||
if (strArr != null) {
|
||||
int length = strArr.length;
|
||||
Iterator it2 = treeSet.iterator();
|
||||
while (it2.hasNext()) {
|
||||
String classObj = ((ClassObj) it2.next()).toString();
|
||||
int i = 0;
|
||||
while (true) {
|
||||
if (i >= length) {
|
||||
break;
|
||||
}
|
||||
if (classObj.startsWith(strArr[i])) {
|
||||
it2.remove();
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (ClassObj classObj2 : treeSet) {
|
||||
int lastIndexOf = classObj2.mClassName.lastIndexOf(46);
|
||||
String substring = lastIndexOf != -1 ? classObj2.mClassName.substring(0, lastIndexOf) : DEFAULT_PACKAGE;
|
||||
Set set = (Set) treeMap.get(substring);
|
||||
if (set == null) {
|
||||
set = new TreeSet();
|
||||
treeMap.put(substring, set);
|
||||
}
|
||||
set.add(classObj2);
|
||||
}
|
||||
return treeMap;
|
||||
}
|
||||
|
||||
public static Collection<ClassObj> commonClasses(Snapshot snapshot, Snapshot snapshot2) {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
Iterator<Heap> it = snapshot.getHeaps().iterator();
|
||||
while (it.hasNext()) {
|
||||
for (ClassObj classObj : it.next().getClasses()) {
|
||||
if (snapshot2.findClass(classObj.getClassName()) != null) {
|
||||
arrayList.add(classObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public static ClassObj findClass(Snapshot snapshot, String str) {
|
||||
return snapshot.findClass(str);
|
||||
}
|
||||
|
||||
public static Instance findObject(Snapshot snapshot, String str) {
|
||||
return snapshot.findInstance(Long.parseLong(str, 16));
|
||||
}
|
||||
|
||||
public static Collection<RootObj> getRoots(Snapshot snapshot) {
|
||||
HashSet hashSet = new HashSet();
|
||||
Iterator<Heap> it = snapshot.mHeaps.iterator();
|
||||
while (it.hasNext()) {
|
||||
hashSet.addAll(it.next().mRoots);
|
||||
}
|
||||
return hashSet;
|
||||
}
|
||||
|
||||
public static Instance[] instancesOf(Snapshot snapshot, String str) {
|
||||
ClassObj findClass = snapshot.findClass(str);
|
||||
if (findClass != null) {
|
||||
List<Instance> instancesList = findClass.getInstancesList();
|
||||
return (Instance[]) instancesList.toArray(new Instance[instancesList.size()]);
|
||||
}
|
||||
throw new IllegalArgumentException("Class not found: " + str);
|
||||
}
|
||||
|
||||
public static final Instance[] newInstances(Snapshot snapshot, Snapshot snapshot2) {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
Iterator<Heap> it = snapshot2.mHeaps.iterator();
|
||||
while (it.hasNext()) {
|
||||
Heap next = it.next();
|
||||
Heap heap = snapshot.getHeap(next.getName());
|
||||
if (heap != null) {
|
||||
for (Instance instance : next.getInstances()) {
|
||||
Instance heap2 = heap.getInstance(instance.mId);
|
||||
if (heap2 == null || instance.getClassObj() != heap2.getClassObj()) {
|
||||
arrayList.add(instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return (Instance[]) arrayList.toArray(new Instance[arrayList.size()]);
|
||||
}
|
||||
|
||||
private static ArrayList<ClassObj> traverseSubclasses(ClassObj classObj) {
|
||||
ArrayList<ClassObj> arrayList = new ArrayList<>();
|
||||
for (ClassObj classObj2 : classObj.mSubclasses) {
|
||||
arrayList.add(classObj2);
|
||||
arrayList.addAll(traverseSubclasses(classObj2));
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
}
|
50
sources/com/squareup/haha/perflib/RootObj.java
Normal file
50
sources/com/squareup/haha/perflib/RootObj.java
Normal file
@@ -0,0 +1,50 @@
|
||||
package com.squareup.haha.perflib;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class RootObj extends Instance {
|
||||
public static final String UNDEFINED_CLASS_NAME = "no class defined!!";
|
||||
int mIndex;
|
||||
int mThread;
|
||||
RootType mType;
|
||||
|
||||
public RootObj(RootType rootType) {
|
||||
this(rootType, 0L, 0, null);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.perflib.Instance
|
||||
public final void accept(Visitor visitor) {
|
||||
visitor.visitRootObj(this);
|
||||
Instance referredInstance = getReferredInstance();
|
||||
if (referredInstance != null) {
|
||||
visitor.visitLater(null, referredInstance);
|
||||
}
|
||||
}
|
||||
|
||||
public final String getClassName(Snapshot snapshot) {
|
||||
ClassObj findClass = this.mType == RootType.SYSTEM_CLASS ? snapshot.findClass(this.mId) : snapshot.findInstance(this.mId).getClassObj();
|
||||
return findClass == null ? UNDEFINED_CLASS_NAME : findClass.mClassName;
|
||||
}
|
||||
|
||||
public Instance getReferredInstance() {
|
||||
return this.mType == RootType.SYSTEM_CLASS ? this.mHeap.mSnapshot.findClass(this.mId) : this.mHeap.mSnapshot.findInstance(this.mId);
|
||||
}
|
||||
|
||||
public RootType getRootType() {
|
||||
return this.mType;
|
||||
}
|
||||
|
||||
public final String toString() {
|
||||
return String.format("%s@0x%08x", this.mType.getName(), Long.valueOf(this.mId));
|
||||
}
|
||||
|
||||
public RootObj(RootType rootType, long j) {
|
||||
this(rootType, j, 0, null);
|
||||
}
|
||||
|
||||
public RootObj(RootType rootType, long j, int i, StackTrace stackTrace) {
|
||||
super(j, stackTrace);
|
||||
this.mType = RootType.UNKNOWN;
|
||||
this.mType = rootType;
|
||||
this.mThread = i;
|
||||
}
|
||||
}
|
40
sources/com/squareup/haha/perflib/RootType.java
Normal file
40
sources/com/squareup/haha/perflib/RootType.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package com.squareup.haha.perflib;
|
||||
|
||||
import com.ubt.jimu.diy.model.CategoryModel;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public enum RootType {
|
||||
UNREACHABLE(0, "unreachable object"),
|
||||
INVALID_TYPE(1, "invalid type"),
|
||||
INTERNED_STRING(2, "interned string"),
|
||||
UNKNOWN(3, CategoryModel.unknown),
|
||||
SYSTEM_CLASS(4, "system class"),
|
||||
VM_INTERNAL(5, "vm internal"),
|
||||
DEBUGGER(6, "debugger"),
|
||||
NATIVE_LOCAL(7, "native local"),
|
||||
NATIVE_STATIC(8, "native static"),
|
||||
THREAD_BLOCK(9, "thread block"),
|
||||
BUSY_MONITOR(10, "busy monitor"),
|
||||
NATIVE_MONITOR(11, "native monitor"),
|
||||
REFERENCE_CLEANUP(12, "reference cleanup"),
|
||||
FINALIZING(13, "finalizing"),
|
||||
JAVA_LOCAL(14, "java local"),
|
||||
NATIVE_STACK(15, "native stack"),
|
||||
JAVA_STATIC(16, "java static");
|
||||
|
||||
private final String mName;
|
||||
private final int mType;
|
||||
|
||||
RootType(int i, String str) {
|
||||
this.mType = i;
|
||||
this.mName = str;
|
||||
}
|
||||
|
||||
public final String getName() {
|
||||
return this.mName;
|
||||
}
|
||||
|
||||
public final int getType() {
|
||||
return this.mType;
|
||||
}
|
||||
}
|
278
sources/com/squareup/haha/perflib/Snapshot.java
Normal file
278
sources/com/squareup/haha/perflib/Snapshot.java
Normal file
@@ -0,0 +1,278 @@
|
||||
package com.squareup.haha.perflib;
|
||||
|
||||
import com.squareup.haha.guava.collect.ImmutableList;
|
||||
import com.squareup.haha.guava.collect.UnmodifiableIterator;
|
||||
import com.squareup.haha.perflib.analysis.Dominators;
|
||||
import com.squareup.haha.perflib.analysis.ShortestDistanceVisitor;
|
||||
import com.squareup.haha.perflib.analysis.TopologicalSort;
|
||||
import com.squareup.haha.perflib.io.HprofBuffer;
|
||||
import gnu.trove.THashSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Snapshot {
|
||||
static final /* synthetic */ boolean $assertionsDisabled = false;
|
||||
private static final int DEFAULT_HEAP_ID = 0;
|
||||
private static final String JAVA_LANG_CLASS = "java.lang.Class";
|
||||
public static final Instance SENTINEL_ROOT = new RootObj(RootType.UNKNOWN);
|
||||
final HprofBuffer mBuffer;
|
||||
Heap mCurrentHeap;
|
||||
private Dominators mDominators;
|
||||
private ImmutableList<Instance> mTopSort;
|
||||
private int[] mTypeSizes;
|
||||
ArrayList<Heap> mHeaps = new ArrayList<>();
|
||||
private THashSet<ClassObj> mReferenceClasses = new THashSet<>();
|
||||
private long mIdSizeMask = 4294967295L;
|
||||
|
||||
public Snapshot(HprofBuffer hprofBuffer) {
|
||||
this.mBuffer = hprofBuffer;
|
||||
setToDefaultHeap();
|
||||
}
|
||||
|
||||
public final void addClass(long j, ClassObj classObj) {
|
||||
this.mCurrentHeap.addClass(j, classObj);
|
||||
classObj.setHeap(this.mCurrentHeap);
|
||||
}
|
||||
|
||||
public final void addInstance(long j, Instance instance) {
|
||||
this.mCurrentHeap.addInstance(j, instance);
|
||||
instance.setHeap(this.mCurrentHeap);
|
||||
}
|
||||
|
||||
public final void addRoot(RootObj rootObj) {
|
||||
this.mCurrentHeap.addRoot(rootObj);
|
||||
rootObj.setHeap(this.mCurrentHeap);
|
||||
}
|
||||
|
||||
public final void addStackFrame(StackFrame stackFrame) {
|
||||
this.mCurrentHeap.addStackFrame(stackFrame);
|
||||
}
|
||||
|
||||
public final void addStackTrace(StackTrace stackTrace) {
|
||||
this.mCurrentHeap.addStackTrace(stackTrace);
|
||||
}
|
||||
|
||||
public final void addThread(ThreadObj threadObj, int i) {
|
||||
this.mCurrentHeap.addThread(threadObj, i);
|
||||
}
|
||||
|
||||
public void computeDominators() {
|
||||
if (this.mDominators == null) {
|
||||
this.mTopSort = TopologicalSort.compute(getGCRoots());
|
||||
this.mDominators = new Dominators(this, this.mTopSort);
|
||||
this.mDominators.computeRetainedSizes();
|
||||
new ShortestDistanceVisitor().doVisit(getGCRoots());
|
||||
}
|
||||
}
|
||||
|
||||
public final void dumpInstanceCounts() {
|
||||
Iterator<Heap> it = this.mHeaps.iterator();
|
||||
while (it.hasNext()) {
|
||||
Heap next = it.next();
|
||||
System.out.println("+------------------ instance counts for heap: " + next.getName());
|
||||
next.dumpInstanceCounts();
|
||||
}
|
||||
}
|
||||
|
||||
public final void dumpSizes() {
|
||||
Iterator<Heap> it = this.mHeaps.iterator();
|
||||
while (it.hasNext()) {
|
||||
Heap next = it.next();
|
||||
System.out.println("+------------------ sizes for heap: " + next.getName());
|
||||
next.dumpSizes();
|
||||
}
|
||||
}
|
||||
|
||||
public final void dumpSubclasses() {
|
||||
Iterator<Heap> it = this.mHeaps.iterator();
|
||||
while (it.hasNext()) {
|
||||
Heap next = it.next();
|
||||
System.out.println("+------------------ subclasses for heap: " + next.getName());
|
||||
next.dumpSubclasses();
|
||||
}
|
||||
}
|
||||
|
||||
public List<ClassObj> findAllDescendantClasses(String str) {
|
||||
Collection<ClassObj> findClasses = findClasses(str);
|
||||
ArrayList arrayList = new ArrayList();
|
||||
Iterator<ClassObj> it = findClasses.iterator();
|
||||
while (it.hasNext()) {
|
||||
arrayList.addAll(it.next().getDescendantClasses());
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public final ClassObj findClass(long j) {
|
||||
for (int i = 0; i < this.mHeaps.size(); i++) {
|
||||
ClassObj classObj = this.mHeaps.get(i).getClass(j);
|
||||
if (classObj != null) {
|
||||
return classObj;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public final Collection<ClassObj> findClasses(String str) {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
for (int i = 0; i < this.mHeaps.size(); i++) {
|
||||
arrayList.addAll(this.mHeaps.get(i).getClasses(str));
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public final Instance findInstance(long j) {
|
||||
for (int i = 0; i < this.mHeaps.size(); i++) {
|
||||
Instance heap = this.mHeaps.get(i).getInstance(j);
|
||||
if (heap != null) {
|
||||
return heap;
|
||||
}
|
||||
}
|
||||
return findClass(j);
|
||||
}
|
||||
|
||||
public Collection<RootObj> getGCRoots() {
|
||||
return this.mHeaps.get(0).mRoots;
|
||||
}
|
||||
|
||||
public Heap getHeap(int i) {
|
||||
for (int i2 = 0; i2 < this.mHeaps.size(); i2++) {
|
||||
if (this.mHeaps.get(i2).getId() == i) {
|
||||
return this.mHeaps.get(i2);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getHeapIndex(Heap heap) {
|
||||
return this.mHeaps.indexOf(heap);
|
||||
}
|
||||
|
||||
public Collection<Heap> getHeaps() {
|
||||
return this.mHeaps;
|
||||
}
|
||||
|
||||
public final long getIdSizeMask() {
|
||||
return this.mIdSizeMask;
|
||||
}
|
||||
|
||||
public List<Instance> getReachableInstances() {
|
||||
ArrayList arrayList = new ArrayList(this.mTopSort.size());
|
||||
UnmodifiableIterator<Instance> it = this.mTopSort.iterator();
|
||||
while (it.hasNext()) {
|
||||
Instance next = it.next();
|
||||
if (next.getImmediateDominator() != null) {
|
||||
arrayList.add(next);
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public final StackFrame getStackFrame(long j) {
|
||||
return this.mCurrentHeap.getStackFrame(j);
|
||||
}
|
||||
|
||||
public final StackTrace getStackTrace(int i) {
|
||||
return this.mCurrentHeap.getStackTrace(i);
|
||||
}
|
||||
|
||||
public final StackTrace getStackTraceAtDepth(int i, int i2) {
|
||||
return this.mCurrentHeap.getStackTraceAtDepth(i, i2);
|
||||
}
|
||||
|
||||
public final ThreadObj getThread(int i) {
|
||||
return this.mCurrentHeap.getThread(i);
|
||||
}
|
||||
|
||||
public ImmutableList<Instance> getTopologicalOrdering() {
|
||||
return this.mTopSort;
|
||||
}
|
||||
|
||||
public final int getTypeSize(Type type) {
|
||||
return this.mTypeSizes[type.getTypeId()];
|
||||
}
|
||||
|
||||
public void resolveClasses() {
|
||||
ClassObj findClass = findClass(JAVA_LANG_CLASS);
|
||||
int instanceSize = findClass != null ? findClass.getInstanceSize() : 0;
|
||||
Iterator<Heap> it = this.mHeaps.iterator();
|
||||
while (it.hasNext()) {
|
||||
Heap next = it.next();
|
||||
for (ClassObj classObj : next.getClasses()) {
|
||||
ClassObj superClassObj = classObj.getSuperClassObj();
|
||||
if (superClassObj != null) {
|
||||
superClassObj.addSubclass(classObj);
|
||||
}
|
||||
int i = instanceSize;
|
||||
for (Field field : classObj.mStaticFields) {
|
||||
i += getTypeSize(field.getType());
|
||||
}
|
||||
classObj.setSize(i);
|
||||
}
|
||||
for (Instance instance : next.getInstances()) {
|
||||
ClassObj classObj2 = instance.getClassObj();
|
||||
if (classObj2 != null) {
|
||||
classObj2.addInstance(next.getId(), instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resolveReferences() {
|
||||
for (ClassObj classObj : findAllDescendantClasses(ClassObj.getReferenceClassName())) {
|
||||
classObj.setIsSoftReference();
|
||||
this.mReferenceClasses.add(classObj);
|
||||
}
|
||||
}
|
||||
|
||||
public Heap setHeapTo(int i, String str) {
|
||||
Heap heap = getHeap(i);
|
||||
if (heap == null) {
|
||||
heap = new Heap(i, str);
|
||||
heap.mSnapshot = this;
|
||||
this.mHeaps.add(heap);
|
||||
}
|
||||
this.mCurrentHeap = heap;
|
||||
return this.mCurrentHeap;
|
||||
}
|
||||
|
||||
public final void setIdSize(int i) {
|
||||
int i2 = -1;
|
||||
for (int i3 = 0; i3 < Type.values().length; i3++) {
|
||||
i2 = Math.max(Type.values()[i3].getTypeId(), i2);
|
||||
}
|
||||
this.mTypeSizes = new int[i2 + 1];
|
||||
Arrays.fill(this.mTypeSizes, -1);
|
||||
for (int i4 = 0; i4 < Type.values().length; i4++) {
|
||||
this.mTypeSizes[Type.values()[i4].getTypeId()] = Type.values()[i4].getSize();
|
||||
}
|
||||
this.mTypeSizes[Type.OBJECT.getTypeId()] = i;
|
||||
this.mIdSizeMask = (-1) >>> ((8 - i) << 3);
|
||||
}
|
||||
|
||||
public Heap setToDefaultHeap() {
|
||||
return setHeapTo(0, "default");
|
||||
}
|
||||
|
||||
public final ClassObj findClass(String str) {
|
||||
for (int i = 0; i < this.mHeaps.size(); i++) {
|
||||
ClassObj classObj = this.mHeaps.get(i).getClass(str);
|
||||
if (classObj != null) {
|
||||
return classObj;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Heap getHeap(String str) {
|
||||
for (int i = 0; i < this.mHeaps.size(); i++) {
|
||||
if (str.equals(this.mHeaps.get(i).getName())) {
|
||||
return this.mHeaps.get(i);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
33
sources/com/squareup/haha/perflib/StackFrame.java
Normal file
33
sources/com/squareup/haha/perflib/StackFrame.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package com.squareup.haha.perflib;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class StackFrame {
|
||||
public static final int COMPILED_METHOD = -2;
|
||||
public static final int NATIVE_METHOD = -3;
|
||||
public static final int NO_LINE_NUMBER = 0;
|
||||
public static final int UNKNOWN_LOCATION = -1;
|
||||
String mFilename;
|
||||
long mId;
|
||||
int mLineNumber;
|
||||
String mMethodName;
|
||||
int mSerialNumber;
|
||||
String mSignature;
|
||||
|
||||
public StackFrame(long j, String str, String str2, String str3, int i, int i2) {
|
||||
this.mId = j;
|
||||
this.mMethodName = str;
|
||||
this.mSignature = str2;
|
||||
this.mFilename = str3;
|
||||
this.mSerialNumber = i;
|
||||
this.mLineNumber = i2;
|
||||
}
|
||||
|
||||
private String lineNumberString() {
|
||||
int i = this.mLineNumber;
|
||||
return i != -3 ? i != -2 ? i != -1 ? i != 0 ? String.valueOf(i) : "No line number" : "Unknown line number" : "Compiled method" : "Native method";
|
||||
}
|
||||
|
||||
public final String toString() {
|
||||
return this.mMethodName + this.mSignature.replace('/', '.') + " - " + this.mFilename + ":" + lineNumberString();
|
||||
}
|
||||
}
|
38
sources/com/squareup/haha/perflib/StackTrace.java
Normal file
38
sources/com/squareup/haha/perflib/StackTrace.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package com.squareup.haha.perflib;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class StackTrace {
|
||||
StackFrame[] mFrames;
|
||||
int mSerialNumber;
|
||||
int mThreadSerialNumber;
|
||||
StackTrace mParent = null;
|
||||
int mOffset = 0;
|
||||
|
||||
private StackTrace() {
|
||||
}
|
||||
|
||||
public final void dump() {
|
||||
int length = this.mFrames.length;
|
||||
for (int i = 0; i < length; i++) {
|
||||
System.out.println(this.mFrames[i].toString());
|
||||
}
|
||||
}
|
||||
|
||||
public final StackTrace fromDepth(int i) {
|
||||
StackTrace stackTrace = new StackTrace();
|
||||
StackTrace stackTrace2 = this.mParent;
|
||||
if (stackTrace2 != null) {
|
||||
stackTrace.mParent = stackTrace2;
|
||||
} else {
|
||||
stackTrace.mParent = this;
|
||||
}
|
||||
stackTrace.mOffset = i + this.mOffset;
|
||||
return stackTrace;
|
||||
}
|
||||
|
||||
public StackTrace(int i, int i2, StackFrame[] stackFrameArr) {
|
||||
this.mSerialNumber = i;
|
||||
this.mThreadSerialNumber = i2;
|
||||
this.mFrames = stackFrameArr;
|
||||
}
|
||||
}
|
12
sources/com/squareup/haha/perflib/ThreadObj.java
Normal file
12
sources/com/squareup/haha/perflib/ThreadObj.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.squareup.haha.perflib;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ThreadObj {
|
||||
long mId;
|
||||
int mStackTrace;
|
||||
|
||||
public ThreadObj(long j, int i) {
|
||||
this.mId = j;
|
||||
this.mStackTrace = i;
|
||||
}
|
||||
}
|
107
sources/com/squareup/haha/perflib/Type.java
Normal file
107
sources/com/squareup/haha/perflib/Type.java
Normal file
@@ -0,0 +1,107 @@
|
||||
package com.squareup.haha.perflib;
|
||||
|
||||
import com.squareup.haha.guava.collect.Maps;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public enum Type {
|
||||
OBJECT(2, 0),
|
||||
BOOLEAN(4, 1),
|
||||
CHAR(5, 2),
|
||||
FLOAT(6, 4),
|
||||
DOUBLE(7, 8),
|
||||
BYTE(8, 1),
|
||||
SHORT(9, 2),
|
||||
INT(10, 4),
|
||||
LONG(11, 8);
|
||||
|
||||
private static Map<Integer, Type> sTypeMap = Maps.newHashMap();
|
||||
private int mId;
|
||||
private int mSize;
|
||||
|
||||
/* renamed from: com.squareup.haha.perflib.Type$1, reason: invalid class name */
|
||||
static /* synthetic */ class AnonymousClass1 {
|
||||
static final /* synthetic */ int[] $SwitchMap$com$android$tools$perflib$heap$Type = new int[Type.values().length];
|
||||
|
||||
static {
|
||||
try {
|
||||
$SwitchMap$com$android$tools$perflib$heap$Type[Type.BOOLEAN.ordinal()] = 1;
|
||||
} catch (NoSuchFieldError unused) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$android$tools$perflib$heap$Type[Type.CHAR.ordinal()] = 2;
|
||||
} catch (NoSuchFieldError unused2) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$android$tools$perflib$heap$Type[Type.FLOAT.ordinal()] = 3;
|
||||
} catch (NoSuchFieldError unused3) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$android$tools$perflib$heap$Type[Type.DOUBLE.ordinal()] = 4;
|
||||
} catch (NoSuchFieldError unused4) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$android$tools$perflib$heap$Type[Type.BYTE.ordinal()] = 5;
|
||||
} catch (NoSuchFieldError unused5) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$android$tools$perflib$heap$Type[Type.SHORT.ordinal()] = 6;
|
||||
} catch (NoSuchFieldError unused6) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$android$tools$perflib$heap$Type[Type.INT.ordinal()] = 7;
|
||||
} catch (NoSuchFieldError unused7) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$android$tools$perflib$heap$Type[Type.LONG.ordinal()] = 8;
|
||||
} catch (NoSuchFieldError unused8) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
for (Type type : values()) {
|
||||
sTypeMap.put(Integer.valueOf(type.mId), type);
|
||||
}
|
||||
}
|
||||
|
||||
Type(int i, int i2) {
|
||||
this.mId = i;
|
||||
this.mSize = i2;
|
||||
}
|
||||
|
||||
public static String getClassNameOfPrimitiveArray(Type type) {
|
||||
switch (AnonymousClass1.$SwitchMap$com$android$tools$perflib$heap$Type[type.ordinal()]) {
|
||||
case 1:
|
||||
return "boolean[]";
|
||||
case 2:
|
||||
return "char[]";
|
||||
case 3:
|
||||
return "float[]";
|
||||
case 4:
|
||||
return "double[]";
|
||||
case 5:
|
||||
return "byte[]";
|
||||
case 6:
|
||||
return "short[]";
|
||||
case 7:
|
||||
return "int[]";
|
||||
case 8:
|
||||
return "long[]";
|
||||
default:
|
||||
throw new IllegalArgumentException("OBJECT type is not a primitive type");
|
||||
}
|
||||
}
|
||||
|
||||
public static Type getType(int i) {
|
||||
return sTypeMap.get(Integer.valueOf(i));
|
||||
}
|
||||
|
||||
public final int getSize() {
|
||||
return this.mSize;
|
||||
}
|
||||
|
||||
public final int getTypeId() {
|
||||
return this.mId;
|
||||
}
|
||||
}
|
22
sources/com/squareup/haha/perflib/Value.java
Normal file
22
sources/com/squareup/haha/perflib/Value.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package com.squareup.haha.perflib;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Value {
|
||||
private final Instance instance;
|
||||
private Object mValue;
|
||||
|
||||
public Value(Instance instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return this.mValue;
|
||||
}
|
||||
|
||||
public void setValue(Object obj) {
|
||||
this.mValue = obj;
|
||||
if (obj instanceof Instance) {
|
||||
((Instance) obj).addReference(null, this.instance);
|
||||
}
|
||||
}
|
||||
}
|
14
sources/com/squareup/haha/perflib/Visitor.java
Normal file
14
sources/com/squareup/haha/perflib/Visitor.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.squareup.haha.perflib;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface Visitor {
|
||||
void visitArrayInstance(ArrayInstance arrayInstance);
|
||||
|
||||
void visitClassInstance(ClassInstance classInstance);
|
||||
|
||||
void visitClassObj(ClassObj classObj);
|
||||
|
||||
void visitLater(Instance instance, Instance instance2);
|
||||
|
||||
void visitRootObj(RootObj rootObj);
|
||||
}
|
76
sources/com/squareup/haha/perflib/analysis/Dominators.java
Normal file
76
sources/com/squareup/haha/perflib/analysis/Dominators.java
Normal file
@@ -0,0 +1,76 @@
|
||||
package com.squareup.haha.perflib.analysis;
|
||||
|
||||
import com.squareup.haha.guava.collect.ImmutableList;
|
||||
import com.squareup.haha.guava.collect.Iterables;
|
||||
import com.squareup.haha.perflib.Heap;
|
||||
import com.squareup.haha.perflib.Instance;
|
||||
import com.squareup.haha.perflib.RootObj;
|
||||
import com.squareup.haha.perflib.Snapshot;
|
||||
import java.util.Iterator;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Dominators {
|
||||
private final Snapshot mSnapshot;
|
||||
private final ImmutableList<Instance> mTopSort;
|
||||
|
||||
public Dominators(Snapshot snapshot, ImmutableList<Instance> immutableList) {
|
||||
this.mSnapshot = snapshot;
|
||||
this.mTopSort = immutableList;
|
||||
Iterator<RootObj> it = snapshot.getGCRoots().iterator();
|
||||
while (it.hasNext()) {
|
||||
Instance referredInstance = it.next().getReferredInstance();
|
||||
if (referredInstance != null) {
|
||||
referredInstance.setImmediateDominator(Snapshot.SENTINEL_ROOT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void computeDominators() {
|
||||
boolean z;
|
||||
for (boolean z2 = true; z2; z2 = z) {
|
||||
z = false;
|
||||
for (int i = 0; i < this.mTopSort.size(); i++) {
|
||||
Instance instance = this.mTopSort.get(i);
|
||||
if (instance.getImmediateDominator() != Snapshot.SENTINEL_ROOT) {
|
||||
Instance instance2 = null;
|
||||
for (int i2 = 0; i2 < instance.getHardReferences().size(); i2++) {
|
||||
Instance instance3 = instance.getHardReferences().get(i2);
|
||||
if (instance3.getImmediateDominator() != null) {
|
||||
if (instance2 == null) {
|
||||
instance2 = instance3;
|
||||
} else {
|
||||
while (instance2 != instance3) {
|
||||
if (instance2.getTopologicalOrder() < instance3.getTopologicalOrder()) {
|
||||
instance3 = instance3.getImmediateDominator();
|
||||
} else {
|
||||
instance2 = instance2.getImmediateDominator();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (instance.getImmediateDominator() != instance2) {
|
||||
instance.setImmediateDominator(instance2);
|
||||
z = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void computeRetainedSizes() {
|
||||
for (Heap heap : this.mSnapshot.getHeaps()) {
|
||||
Iterator it = Iterables.concat(heap.getClasses(), heap.getInstances()).iterator();
|
||||
while (it.hasNext()) {
|
||||
((Instance) it.next()).resetRetainedSize();
|
||||
}
|
||||
}
|
||||
computeDominators();
|
||||
for (Instance instance : this.mSnapshot.getReachableInstances()) {
|
||||
int heapIndex = this.mSnapshot.getHeapIndex(instance.getHeap());
|
||||
for (Instance immediateDominator = instance.getImmediateDominator(); immediateDominator != Snapshot.SENTINEL_ROOT; immediateDominator = immediateDominator.getImmediateDominator()) {
|
||||
immediateDominator.addRetainedSize(heapIndex, instance.getSize());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
package com.squareup.haha.perflib.analysis;
|
||||
|
||||
import com.ijm.dataencryption.de.DataDecryptTool;
|
||||
import com.squareup.haha.perflib.Instance;
|
||||
import com.squareup.haha.perflib.NonRecursiveVisitor;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.PriorityQueue;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ShortestDistanceVisitor extends NonRecursiveVisitor {
|
||||
private PriorityQueue<Instance> mPriorityQueue = new PriorityQueue<>(DataDecryptTool.DECRYPT_SP_FILE, new Comparator<Instance>() { // from class: com.squareup.haha.perflib.analysis.ShortestDistanceVisitor.1
|
||||
@Override // java.util.Comparator
|
||||
public int compare(Instance instance, Instance instance2) {
|
||||
return instance.getDistanceToGcRoot() - instance2.getDistanceToGcRoot();
|
||||
}
|
||||
});
|
||||
private Instance mPreviousInstance = null;
|
||||
private int mVisitDistance = 0;
|
||||
|
||||
@Override // com.squareup.haha.perflib.NonRecursiveVisitor
|
||||
public void doVisit(Iterable<? extends Instance> iterable) {
|
||||
Iterator<? extends Instance> it = iterable.iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().accept(this);
|
||||
}
|
||||
while (!this.mPriorityQueue.isEmpty()) {
|
||||
Instance poll = this.mPriorityQueue.poll();
|
||||
this.mVisitDistance = poll.getDistanceToGcRoot() + 1;
|
||||
this.mPreviousInstance = poll;
|
||||
poll.accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.perflib.NonRecursiveVisitor, com.squareup.haha.perflib.Visitor
|
||||
public void visitLater(Instance instance, Instance instance2) {
|
||||
if (this.mVisitDistance < instance2.getDistanceToGcRoot()) {
|
||||
if (instance == null || instance2.getSoftReferences() == null || !instance2.getSoftReferences().contains(instance) || instance2.getIsSoftReference()) {
|
||||
instance2.setDistanceToGcRoot(this.mVisitDistance);
|
||||
instance2.setNextInstanceToGcRoot(this.mPreviousInstance);
|
||||
this.mPriorityQueue.add(instance2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
package com.squareup.haha.perflib.analysis;
|
||||
|
||||
import com.squareup.haha.guava.base.Joiner;
|
||||
import com.squareup.haha.guava.collect.ImmutableList;
|
||||
import com.squareup.haha.guava.collect.UnmodifiableIterator;
|
||||
import com.squareup.haha.perflib.Instance;
|
||||
import com.squareup.haha.perflib.NonRecursiveVisitor;
|
||||
import com.squareup.haha.perflib.RootObj;
|
||||
import com.squareup.haha.perflib.Snapshot;
|
||||
import gnu.trove.TLongHashSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class TopologicalSort {
|
||||
|
||||
static class TopologicalSortVisitor extends NonRecursiveVisitor {
|
||||
private final List<Instance> mPostorder;
|
||||
private final TLongHashSet mVisited;
|
||||
|
||||
private TopologicalSortVisitor() {
|
||||
this.mVisited = new TLongHashSet();
|
||||
this.mPostorder = new ArrayList();
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.perflib.NonRecursiveVisitor
|
||||
public void doVisit(Iterable<? extends Instance> iterable) {
|
||||
Iterator<? extends Instance> it = iterable.iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().accept(this);
|
||||
}
|
||||
while (!this.mStack.isEmpty()) {
|
||||
Instance peek = this.mStack.peek();
|
||||
if (this.mSeen.add(peek.getId())) {
|
||||
peek.accept(this);
|
||||
} else {
|
||||
this.mStack.pop();
|
||||
if (this.mVisited.add(peek.getId())) {
|
||||
this.mPostorder.add(peek);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImmutableList<Instance> getOrderedInstances() {
|
||||
return ImmutableList.copyOf((Collection) Joiner.reverse(this.mPostorder));
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.perflib.NonRecursiveVisitor, com.squareup.haha.perflib.Visitor
|
||||
public void visitLater(Instance instance, Instance instance2) {
|
||||
if (this.mSeen.contains(instance2.getId())) {
|
||||
return;
|
||||
}
|
||||
this.mStack.push(instance2);
|
||||
}
|
||||
}
|
||||
|
||||
public static ImmutableList<Instance> compute(Iterable<RootObj> iterable) {
|
||||
TopologicalSortVisitor topologicalSortVisitor = new TopologicalSortVisitor();
|
||||
topologicalSortVisitor.doVisit(iterable);
|
||||
ImmutableList<Instance> orderedInstances = topologicalSortVisitor.getOrderedInstances();
|
||||
int i = 0;
|
||||
Snapshot.SENTINEL_ROOT.setTopologicalOrder(0);
|
||||
UnmodifiableIterator<Instance> it = orderedInstances.iterator();
|
||||
while (it.hasNext()) {
|
||||
i++;
|
||||
it.next().setTopologicalOrder(i);
|
||||
}
|
||||
return orderedInstances;
|
||||
}
|
||||
}
|
34
sources/com/squareup/haha/perflib/io/HprofBuffer.java
Normal file
34
sources/com/squareup/haha/perflib/io/HprofBuffer.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package com.squareup.haha.perflib.io;
|
||||
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface HprofBuffer {
|
||||
public static final ByteOrder HPROF_BYTE_ORDER = ByteOrder.BIG_ENDIAN;
|
||||
|
||||
boolean hasRemaining();
|
||||
|
||||
long position();
|
||||
|
||||
void read(byte[] bArr);
|
||||
|
||||
byte readByte();
|
||||
|
||||
char readChar();
|
||||
|
||||
double readDouble();
|
||||
|
||||
float readFloat();
|
||||
|
||||
int readInt();
|
||||
|
||||
long readLong();
|
||||
|
||||
short readShort();
|
||||
|
||||
void readSubSequence(byte[] bArr, int i, int i2);
|
||||
|
||||
long remaining();
|
||||
|
||||
void setPosition(long j);
|
||||
}
|
171
sources/com/squareup/haha/perflib/io/MemoryMappedFileBuffer.java
Normal file
171
sources/com/squareup/haha/perflib/io/MemoryMappedFileBuffer.java
Normal file
@@ -0,0 +1,171 @@
|
||||
package com.squareup.haha.perflib.io;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MemoryMappedFileBuffer implements HprofBuffer {
|
||||
static final /* synthetic */ boolean $assertionsDisabled = false;
|
||||
private static final int DEFAULT_PADDING = 1024;
|
||||
private static final int DEFAULT_SIZE = 1073741824;
|
||||
private final int mBufferSize;
|
||||
private final ByteBuffer[] mByteBuffers;
|
||||
private long mCurrentPosition;
|
||||
private final long mLength;
|
||||
private final int mPadding;
|
||||
|
||||
MemoryMappedFileBuffer(File file, int i, int i2) throws IOException {
|
||||
this.mBufferSize = i;
|
||||
this.mPadding = i2;
|
||||
this.mLength = file.length();
|
||||
int i3 = ((int) (this.mLength / this.mBufferSize)) + 1;
|
||||
this.mByteBuffers = new ByteBuffer[i3];
|
||||
FileInputStream fileInputStream = new FileInputStream(file);
|
||||
long j = 0;
|
||||
for (int i4 = 0; i4 < i3; i4++) {
|
||||
try {
|
||||
this.mByteBuffers[i4] = fileInputStream.getChannel().map(FileChannel.MapMode.READ_ONLY, j, Math.min(this.mLength - j, this.mBufferSize + this.mPadding));
|
||||
this.mByteBuffers[i4].order(HprofBuffer.HPROF_BYTE_ORDER);
|
||||
j += this.mBufferSize;
|
||||
} finally {
|
||||
fileInputStream.close();
|
||||
}
|
||||
}
|
||||
this.mCurrentPosition = 0L;
|
||||
}
|
||||
|
||||
private int getIndex() {
|
||||
return (int) (this.mCurrentPosition / this.mBufferSize);
|
||||
}
|
||||
|
||||
private int getOffset() {
|
||||
return (int) (this.mCurrentPosition % this.mBufferSize);
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
for (int i = 0; i < this.mByteBuffers.length; i++) {
|
||||
try {
|
||||
this.mByteBuffers[i].cleaner().clean();
|
||||
} catch (Exception unused) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.perflib.io.HprofBuffer
|
||||
public boolean hasRemaining() {
|
||||
return this.mCurrentPosition < this.mLength;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.perflib.io.HprofBuffer
|
||||
public long position() {
|
||||
return this.mCurrentPosition;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.perflib.io.HprofBuffer
|
||||
public void read(byte[] bArr) {
|
||||
int index = getIndex();
|
||||
this.mByteBuffers[index].position(getOffset());
|
||||
if (bArr.length <= this.mByteBuffers[index].remaining()) {
|
||||
this.mByteBuffers[index].get(bArr, 0, bArr.length);
|
||||
} else {
|
||||
int position = this.mBufferSize - this.mByteBuffers[index].position();
|
||||
this.mByteBuffers[index].get(bArr, 0, position);
|
||||
int i = index + 1;
|
||||
this.mByteBuffers[i].position(0);
|
||||
this.mByteBuffers[i].get(bArr, position, bArr.length - position);
|
||||
}
|
||||
this.mCurrentPosition += bArr.length;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.perflib.io.HprofBuffer
|
||||
public byte readByte() {
|
||||
byte b = this.mByteBuffers[getIndex()].get(getOffset());
|
||||
this.mCurrentPosition++;
|
||||
return b;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.perflib.io.HprofBuffer
|
||||
public char readChar() {
|
||||
char c = this.mByteBuffers[getIndex()].getChar(getOffset());
|
||||
this.mCurrentPosition += 2;
|
||||
return c;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.perflib.io.HprofBuffer
|
||||
public double readDouble() {
|
||||
double d = this.mByteBuffers[getIndex()].getDouble(getOffset());
|
||||
this.mCurrentPosition += 8;
|
||||
return d;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.perflib.io.HprofBuffer
|
||||
public float readFloat() {
|
||||
float f = this.mByteBuffers[getIndex()].getFloat(getOffset());
|
||||
this.mCurrentPosition += 4;
|
||||
return f;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.perflib.io.HprofBuffer
|
||||
public int readInt() {
|
||||
int i = this.mByteBuffers[getIndex()].getInt(getOffset());
|
||||
this.mCurrentPosition += 4;
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.perflib.io.HprofBuffer
|
||||
public long readLong() {
|
||||
long j = this.mByteBuffers[getIndex()].getLong(getOffset());
|
||||
this.mCurrentPosition += 8;
|
||||
return j;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.perflib.io.HprofBuffer
|
||||
public short readShort() {
|
||||
short s = this.mByteBuffers[getIndex()].getShort(getOffset());
|
||||
this.mCurrentPosition += 2;
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.perflib.io.HprofBuffer
|
||||
public void readSubSequence(byte[] bArr, int i, int i2) {
|
||||
this.mCurrentPosition += i;
|
||||
int index = getIndex();
|
||||
this.mByteBuffers[index].position(getOffset());
|
||||
if (bArr.length <= this.mByteBuffers[index].remaining()) {
|
||||
this.mByteBuffers[index].get(bArr, 0, bArr.length);
|
||||
} else {
|
||||
int position = this.mBufferSize - this.mByteBuffers[index].position();
|
||||
this.mByteBuffers[index].get(bArr, 0, position);
|
||||
int min = Math.min(i2 - position, bArr.length - position);
|
||||
int i3 = ((min + r3) - 1) / this.mBufferSize;
|
||||
int i4 = position;
|
||||
for (int i5 = 0; i5 < i3; i5++) {
|
||||
int min2 = Math.min(min, this.mBufferSize);
|
||||
int i6 = index + 1 + i5;
|
||||
this.mByteBuffers[i6].position(0);
|
||||
this.mByteBuffers[i6].get(bArr, i4, min2);
|
||||
i4 += min2;
|
||||
min -= min2;
|
||||
}
|
||||
}
|
||||
this.mCurrentPosition += Math.min(bArr.length, i2);
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.perflib.io.HprofBuffer
|
||||
public long remaining() {
|
||||
return this.mLength - this.mCurrentPosition;
|
||||
}
|
||||
|
||||
@Override // com.squareup.haha.perflib.io.HprofBuffer
|
||||
public void setPosition(long j) {
|
||||
this.mCurrentPosition = j;
|
||||
}
|
||||
|
||||
public MemoryMappedFileBuffer(File file) throws IOException {
|
||||
this(file, DEFAULT_SIZE, 1024);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user