diff options
author | Roel Spilker <r.spilker@gmail.com> | 2014-01-19 21:49:35 +0100 |
---|---|---|
committer | Roel Spilker <r.spilker@gmail.com> | 2014-01-19 21:49:35 +0100 |
commit | 14cc54527663018cdf7343eefffc8c37fbce93bb (patch) | |
tree | b8b45da7feb1217c31306f7024af37ea287d2b2e /src/core/lombok/eclipse | |
parent | 2ab6cc809d6aec8d253962547cab7e32598b84a7 (diff) | |
download | lombok-14cc54527663018cdf7343eefffc8c37fbce93bb.tar.gz lombok-14cc54527663018cdf7343eefffc8c37fbce93bb.tar.bz2 lombok-14cc54527663018cdf7343eefffc8c37fbce93bb.zip |
Issue 625: use (even) better primes for hashcodes
Diffstat (limited to 'src/core/lombok/eclipse')
-rw-r--r-- | src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java index 8d95ca64..0cc0836e 100644 --- a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java +++ b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java @@ -272,7 +272,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH final boolean isEmpty = fields.isEmpty(); - /* final int PRIME = 277; */ { + /* final int PRIME = X; */ { /* Without fields, PRIME isn't used, and that would trigger a 'local variable not used' warning. */ if (!isEmpty || callSuper) { LocalDeclaration primeDecl = new LocalDeclaration(PRIME, pS, pE); @@ -281,7 +281,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH primeDecl.type = TypeReference.baseTypeReference(TypeIds.T_int, 0); primeDecl.type.sourceStart = pS; primeDecl.type.sourceEnd = pE; setGeneratedBy(primeDecl.type, source); - primeDecl.initialization = makeIntLiteral(String.valueOf(HandlerUtil.PRIME_FOR_HASHCODE).toCharArray(), source); + primeDecl.initialization = makeIntLiteral(String.valueOf(HandlerUtil.primeForHashcode()).toCharArray(), source); statements.add(primeDecl); } } @@ -313,10 +313,10 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH Expression fieldAccessor = createFieldAccessor(field, fieldAccess, source); if (fType.dimensions() == 0 && token != null) { if (Arrays.equals(TypeConstants.BOOLEAN, token)) { - /* booleanField ? 2591 : 2609 */ - IntLiteral intFalse = makeIntLiteral(String.valueOf(HandlerUtil.PRIME_FOR_FALSE).toCharArray(), source); - IntLiteral intTrue = makeIntLiteral(String.valueOf(HandlerUtil.PRIME_FOR_TRUE).toCharArray(), source); - ConditionalExpression intForBool = new ConditionalExpression(fieldAccessor, intFalse, intTrue); + /* booleanField ? X : Y */ + IntLiteral intTrue = makeIntLiteral(String.valueOf(HandlerUtil.primeForTrue()).toCharArray(), source); + IntLiteral intFalse = makeIntLiteral(String.valueOf(HandlerUtil.primeForFalse()).toCharArray(), source); + ConditionalExpression intForBool = new ConditionalExpression(fieldAccessor, intTrue, intFalse); setGeneratedBy(intForBool, source); statements.add(createResultCalculation(source, intForBool)); } else if (Arrays.equals(TypeConstants.LONG, token)) { |