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:10:38 UTC

svn commit: r1576522 - in /lucene/dev/branches/branch_4x: ./ lucene/ lucene/core/ lucene/core/src/java/org/apache/lucene/util/PriorityQueue.java

Author: uschindler
Date: Tue Mar 11 22:10:37 2014
New Revision: 1576522

URL: http://svn.apache.org/r1576522
Log:
Merged revision(s) 1576521 from lucene/dev/trunk:
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/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/lucene/   (props changed)
    lucene/dev/branches/branch_4x/lucene/core/   (props changed)
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/PriorityQueue.java

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/PriorityQueue.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/PriorityQueue.java?rev=1576522&r1=1576521&r2=1576522&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/PriorityQueue.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/PriorityQueue.java Tue Mar 11 22:10:37 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) {