You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2014/03/11 23:09:29 UTC
svn commit: r1576521 -
/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/PriorityQueue.java
Author: uschindler
Date: Tue Mar 11 22:09:29 2014
New Revision: 1576521
URL: http://svn.apache.org/r1576521
Log:
Prevent stupid unchecked warning in Java 7's javac. This is a bug in javac, but we also don't need the SuppressWarnings on the whole ctor.
Modified:
lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/PriorityQueue.java
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/PriorityQueue.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/PriorityQueue.java?rev=1576521&r1=1576520&r2=1576521&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/PriorityQueue.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/PriorityQueue.java Tue Mar 11 22:09:29 2014
@@ -29,7 +29,7 @@ package org.apache.lucene.util;
* @lucene.internal
*/
public abstract class PriorityQueue<T> {
- private int size;
+ private int size = 0;
private final int maxSize;
private final T[] heap;
@@ -37,10 +37,8 @@ public abstract class PriorityQueue<T> {
this(maxSize, true);
}
- @SuppressWarnings("unchecked")
public PriorityQueue(int maxSize, boolean prepopulate) {
- size = 0;
- int heapSize;
+ final int heapSize;
if (0 == maxSize) {
// We allocate 1 extra to avoid if statement in top()
heapSize = 2;
@@ -62,7 +60,9 @@ public abstract class PriorityQueue<T> {
heapSize = maxSize + 1;
}
}
- heap = (T[]) new Object[heapSize]; // T is unbounded type, so this unchecked cast works always
+ // T is unbounded type, so this unchecked cast works always:
+ @SuppressWarnings("unchecked") final T[] h = (T[]) new Object[heapSize];
+ this.heap = h;
this.maxSize = maxSize;
if (prepopulate) {