Improve the performance of Annotation checks

In the circumstance where the annotated element (field/
method/constructor/class) was loaded from a different Dex file
than the annotation:

The previous code would perform a binary
search to determine the type ID of the annotation in the Dex
file of the annotated element. That type ID would then be
compared against the type IDs of annotations present on the
annotated element. The binary search was quite expensive: it
involved various indirections, many small native method calls
and temporary String creation.

Instead, the code now compares the names of the
annotations on the annotated element with the name of the
annotation being searched for. The name of the annotation
is known and cached on the class and is therefore cheap to
get. The name was previously being used to binary search for
the type ID so this appears to be no less correct.

Also removed some unused methods in order to delete the
getFieldIndex() method.

Change-Id: Ib8fb021ddf1221e3eac983aa87e7aea8174720ef
2 files changed