removed unused variable. eliminated unnecessary ObjTypePair creation.

This commit is contained in:
Inderjeet Singh 2011-03-24 22:37:03 +00:00
parent 4d9bec2206
commit ad921a0ee8
2 changed files with 8 additions and 3 deletions

View File

@ -79,6 +79,13 @@ final class ObjectTypePair {
return new ObjectTypePair(obj, actualType, preserveType);
}
Type getMoreSpecificType() {
if (preserveType || obj == null) {
return type;
}
return getActualTypeIfMoreSpecific(type, obj.getClass());
}
// This takes care of situations where the field was declared as an Object, but the
// actual value contains something more specific. See Issue 54.
// TODO (inder): This solution will not work if the field is of a generic type, but

View File

@ -54,9 +54,7 @@ final class ReflectingFieldNavigator {
* @param visitor the visitor to visit each field with
*/
void visitFieldsReflectively(ObjectTypePair objTypePair, Visitor visitor) {
ObjectTypePair currObjTypePair = objTypePair.toMoreSpecificType();
Class<?> topLevelClass = Types.getRawType(currObjTypePair.type);
for (Class<?> curr : getInheritanceHierarchy(currObjTypePair.type)) {
for (Class<?> curr : getInheritanceHierarchy(objTypePair.getMoreSpecificType())) {
navigateClassFields(objTypePair.getObject(), objTypePair.type, curr, visitor);
}
}