Skip to content

Commit

Permalink
HV-1480 Some more optimizations suggested by Sanne
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet authored and gunnarmorling committed Oct 18, 2017
1 parent b74d320 commit bbee5ea
Showing 1 changed file with 14 additions and 15 deletions.
Expand Up @@ -91,7 +91,7 @@ public class ValidationContext<T> {
/**
* The set of already processed unit of works. See {@link ProcessedUnit}.
*/
private final Set<ProcessedUnit> processedUnits;
private final Set<Object> processedUnits;

/**
* Maps an object to a list of paths in which it has been validated. The objects are the bean instances.
Expand Down Expand Up @@ -573,14 +573,12 @@ public <T> ValidationContext<T> forValidateReturnValue(
}
}

private interface ProcessedUnit {
}

private static class BeanGroupProcessedUnit implements ProcessedUnit {
private static final class BeanGroupProcessedUnit {

private final Object bean;
private final Class<?> group;
private final int hashCode;
// these fields are final but we don't mark them as final as an optimization
private Object bean;
private Class<?> group;
private int hashCode;

private BeanGroupProcessedUnit(Object bean, Class<?> group) {
this.bean = bean;
Expand All @@ -593,7 +591,7 @@ public boolean equals(Object o) {
if ( this == o ) {
return true;
}
if ( o == null || getClass() != o.getClass() ) {
if ( o == null || getClass() != BeanGroupProcessedUnit.class ) {
return false;
}

Expand Down Expand Up @@ -621,12 +619,13 @@ private int createHashCode() {
}
}

private static class BeanPathMetaConstraintProcessedUnit implements ProcessedUnit {
private static final class BeanPathMetaConstraintProcessedUnit {

private final Object bean;
private final Path path;
private final MetaConstraint<?> metaConstraint;
private final int hashCode;
// these fields are final but we don't mark them as final as an optimization
private Object bean;
private Path path;
private MetaConstraint<?> metaConstraint;
private int hashCode;

private BeanPathMetaConstraintProcessedUnit(Object bean, Path path, MetaConstraint<?> metaConstraint) {
this.bean = bean;
Expand All @@ -640,7 +639,7 @@ public boolean equals(Object o) {
if ( this == o ) {
return true;
}
if ( o == null || getClass() != o.getClass() ) {
if ( o == null || getClass() != BeanPathMetaConstraintProcessedUnit.class ) {
return false;
}

Expand Down

0 comments on commit bbee5ea

Please sign in to comment.