diff options
author | Jesse Wilson <jessewilson@google.com> | 2011-10-06 13:21:39 -0400 |
---|---|---|
committer | Brian Carlstrom <bdc@google.com> | 2013-04-30 14:50:12 -0700 |
commit | a34f79ba9d4983b96571bbde0a18d352d495f601 (patch) | |
tree | 76e7e01bed7bceda626913951a06e0c158cdaa40 /dex/src | |
parent | 450a197f09d35a07be12a924d4db1ecd2bee65fe (diff) | |
download | libcore-a34f79ba9d4983b96571bbde0a18d352d495f601.zip libcore-a34f79ba9d4983b96571bbde0a18d352d495f601.tar.gz libcore-a34f79ba9d4983b96571bbde0a18d352d495f601.tar.bz2 |
Make Dex access faster by making binarySearch work.
Change-Id: I5f506ef2cd73c2f88f395ad1e1200d79ed33f654
(cherry picked from commit 8cf91498080408179f1b96ae832b581b8547d7c4)
Diffstat (limited to 'dex/src')
-rw-r--r-- | dex/src/main/java/com/android/dex/Dex.java | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/dex/src/main/java/com/android/dex/Dex.java b/dex/src/main/java/com/android/dex/Dex.java index 9ecd133..8a3df96 100644 --- a/dex/src/main/java/com/android/dex/Dex.java +++ b/dex/src/main/java/com/android/dex/Dex.java @@ -36,6 +36,7 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; +import java.util.RandomAccess; import java.util.zip.Adler32; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -54,7 +55,11 @@ public final class Dex { private final TableOfContents tableOfContents = new TableOfContents(); private int nextSectionStart = 0; - private final List<String> strings = new AbstractList<String>() { + private static abstract class AbstractRandomAccessList<T> + extends AbstractList<T> implements RandomAccess { + } + + private List<String> strings = new AbstractRandomAccessList<String>() { @Override public String get(int index) { checkBounds(index, tableOfContents.stringIds.size); return open(tableOfContents.stringIds.off + (index * SizeOf.STRING_ID_ITEM)) @@ -65,7 +70,7 @@ public final class Dex { } }; - private final List<Integer> typeIds = new AbstractList<Integer>() { + private final List<Integer> typeIds = new AbstractRandomAccessList<Integer>() { @Override public Integer get(int index) { checkBounds(index, tableOfContents.typeIds.size); return open(tableOfContents.typeIds.off + (index * SizeOf.TYPE_ID_ITEM)).readInt(); @@ -75,7 +80,7 @@ public final class Dex { } }; - private final List<String> typeNames = new AbstractList<String>() { + private final List<String> typeNames = new AbstractRandomAccessList<String>() { @Override public String get(int index) { checkBounds(index, tableOfContents.typeIds.size); return strings.get(typeIds.get(index)); @@ -85,7 +90,7 @@ public final class Dex { } }; - private final List<ProtoId> protoIds = new AbstractList<ProtoId>() { + private final List<ProtoId> protoIds = new AbstractRandomAccessList<ProtoId>() { @Override public ProtoId get(int index) { checkBounds(index, tableOfContents.protoIds.size); return open(tableOfContents.protoIds.off + (SizeOf.PROTO_ID_ITEM * index)) @@ -96,7 +101,7 @@ public final class Dex { } }; - private final List<FieldId> fieldIds = new AbstractList<FieldId>() { + private final List<FieldId> fieldIds = new AbstractRandomAccessList<FieldId>() { @Override public FieldId get(int index) { checkBounds(index, tableOfContents.fieldIds.size); return open(tableOfContents.fieldIds.off + (SizeOf.MEMBER_ID_ITEM * index)) @@ -107,7 +112,7 @@ public final class Dex { } }; - private final List<MethodId> methodIds = new AbstractList<MethodId>() { + private final List<MethodId> methodIds = new AbstractRandomAccessList<MethodId>() { @Override public MethodId get(int index) { checkBounds(index, tableOfContents.methodIds.size); return open(tableOfContents.methodIds.off + (SizeOf.MEMBER_ID_ITEM * index)) |