Use a SparseArray instead of a HashMap, and add get*Count methods to AnnotationDirectoryItem so we can initialize the SparseArrays with the correct capacity

git-svn-id: https://smali.googlecode.com/svn/trunk@478 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
JesusFreke@JesusFreke.com
2009-09-19 03:18:35 +00:00
parent cd5d4c0385
commit 29f49465ca
2 changed files with 32 additions and 9 deletions

View File

@ -28,12 +28,9 @@
package org.jf.dexlib;
import org.jf.dexlib.EncodedValue.AnnotationEncodedSubValue;
import org.jf.dexlib.Util.ArrayUtils;
import org.jf.dexlib.Util.Input;
import org.jf.dexlib.Util.AnnotatedOutput;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -338,6 +335,13 @@ public class AnnotationDirectoryItem extends Item<AnnotationDirectoryItem> {
void processFieldAnnotations(FieldIdItem field, AnnotationSetItem fieldAnnotations);
}
/**
* @return the number of field annotations in this <code>AnnotationDirectoryItem</code>
*/
public int getFieldAnnotationCount() {
return fieldAnnotationFields.length;
}
/**
* Iterates over the method annotations, calling delegate.processMethodAnnotations for each
* @param delegate the delegate to call
@ -352,11 +356,18 @@ public class AnnotationDirectoryItem extends Item<AnnotationDirectoryItem> {
void processMethodAnnotations(MethodIdItem method, AnnotationSetItem methodAnnotations);
}
/**
* @return the number of method annotations in this <code>AnnotationDirectoryItem</code>
*/
public int getMethodAnnotationCount() {
return methodAnnotationMethods.length;
}
/**
* Iterates over the parameter annotations, calling delegate.processParameterAnnotations for each
* @param delegate the delegate to call
*/
public void iteratParameterAnnotations(ParameterAnnotationIteratorDelegate delegate) {
public void iterateParameterAnnotations(ParameterAnnotationIteratorDelegate delegate) {
for (int i=0; i<parameterAnnotationMethods.length; i++) {
delegate.processParameterAnnotations(parameterAnnotationMethods[i], parameterAnnotations[i]);
}
@ -366,6 +377,13 @@ public class AnnotationDirectoryItem extends Item<AnnotationDirectoryItem> {
void processParameterAnnotations(MethodIdItem method, AnnotationSetRefList parameterAnnotations);
}
/**
* @return the number of parameter annotations in this <code>AnnotationDirectoryItem</code>
*/
public int getParameterAnnotationCount() {
return parameterAnnotationMethods.length;
}
/**
* @return true if this <code>AnnotationDirectoryItem</code> is internable. It is only internable if it has
* only class annotations, but no field, method or parameter annotations