Index: lucene/src/java/org/apache/lucene/util/BytesRefHash.java =================================================================== --- lucene/src/java/org/apache/lucene/util/BytesRefHash.java (revision 1206435) +++ lucene/src/java/org/apache/lucene/util/BytesRefHash.java (working copy) @@ -432,7 +432,7 @@ final int endPos = pos + len; while (pos < endPos) { - code = BytesRef.HASH_PRIME * code + bytes[pos++]; + code = 31 * code + bytes[pos++]; } } else { code = bytesStart[e0]; Index: lucene/src/java/org/apache/lucene/util/CharsRef.java =================================================================== --- lucene/src/java/org/apache/lucene/util/CharsRef.java (revision 1206435) +++ lucene/src/java/org/apache/lucene/util/CharsRef.java (working copy) @@ -26,7 +26,7 @@ * @lucene.internal */ public final class CharsRef implements Comparable, CharSequence, Cloneable { - private static final char[] EMPTY_ARRAY = new char[0]; + private static final char[] EMPTY_CHARS = new char[0]; public char[] chars; public int offset; public int length; @@ -35,7 +35,7 @@ * Creates a new {@link CharsRef} initialized an empty array zero-length */ public CharsRef() { - this(EMPTY_ARRAY, 0, 0); + this(EMPTY_CHARS, 0, 0); } /** @@ -86,28 +86,10 @@ @Override public boolean equals(Object other) { - if (this == other) { - return true; + if (other == null) { + return false; } - - if (other instanceof CharsRef) { - return charsEquals((CharsRef) other); - } - - if (other instanceof CharSequence) { - final CharSequence seq = (CharSequence) other; - if (length == seq.length()) { - int n = length; - int i = offset; - int j = 0; - while (n-- != 0) { - if (chars[i++] != seq.charAt(j++)) - return false; - } - return true; - } - } - return false; + return this.charsEquals((CharsRef) other); } public boolean charsEquals(CharsRef other) { Index: lucene/src/java/org/apache/lucene/util/IntsRef.java =================================================================== --- lucene/src/java/org/apache/lucene/util/IntsRef.java (revision 1206435) +++ lucene/src/java/org/apache/lucene/util/IntsRef.java (working copy) @@ -31,6 +31,7 @@ public int length; public IntsRef() { + ints = EMPTY_INTS; } public IntsRef(int capacity) { @@ -38,6 +39,7 @@ } public IntsRef(int[] ints, int offset, int length) { + assert ints != null; this.ints = ints; this.offset = offset; this.length = length; @@ -61,6 +63,9 @@ @Override public boolean equals(Object other) { + if (other == null) { + return false; + } return this.intsEquals((IntsRef) other); } Index: lucene/src/java/org/apache/lucene/util/BytesRef.java =================================================================== --- lucene/src/java/org/apache/lucene/util/BytesRef.java (revision 1206435) +++ lucene/src/java/org/apache/lucene/util/BytesRef.java (working copy) @@ -25,8 +25,6 @@ * * @lucene.experimental */ public final class BytesRef implements Comparable,Cloneable { - - static final int HASH_PRIME = 31; public static final byte[] EMPTY_BYTES = new byte[0]; /** The contents of the BytesRef. Should never be {@code null}. */ @@ -142,12 +140,12 @@ */ @Override public int hashCode() { - int result = 0; + int hash = 0; final int end = offset + length; for(int i=offset;i