TypeDescriptor efficiently matches equal annotations as well
Issue: SPR-15060
This commit is contained in:
@@ -479,7 +479,7 @@ public class TypeDescriptor implements Serializable {
|
|||||||
}
|
}
|
||||||
if (anns.length > 0) {
|
if (anns.length > 0) {
|
||||||
for (int i = 0; i < anns.length; i++) {
|
for (int i = 0; i < anns.length; i++) {
|
||||||
if (anns[i] != otherAnns[i]) {
|
if (!annotationEquals(anns[i], otherAnns[i])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -487,6 +487,11 @@ public class TypeDescriptor implements Serializable {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean annotationEquals(Annotation ann, Annotation otherAnn) {
|
||||||
|
// Annotation.equals is reflective and pretty slow, so let's check identity and proxy type first.
|
||||||
|
return (ann == otherAnn || (ann.getClass() == otherAnn.getClass() && ann.equals(otherAnn)));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return getType().hashCode();
|
return getType().hashCode();
|
||||||
|
|||||||
Reference in New Issue
Block a user