Patch to improve primitives Array.sort()

Paul Sandoz paul.sandoz at
Fri May 15 16:12:40 UTC 2015

On May 15, 2015, at 11:48 AM, "Chan, Sunny" <Sunny.Chan at> wrote:

> I have provided Paul with an updated patch:

Here it is:

In DualPivotQuicksort

  63     /**
  64      * The maximum length of run in merge sort.
  65      */
  66     private static final int MAX_RUN_LENGTH = 33;
You can remove this constant.

> * The test has been updated using data provider and reduce as much repetition as possible.

Looking much better. Convention-wise if you don't have to deal with any check exceptions using a Supplier is more preferable to Callable. Up to you.

  56     @Test(dataProvider = "arrays")
  57     public void runTests(String testName, Callable<int[]> dataMethod) throws Exception
  58     {
  59         int[] array =;
  60         this.sortAndAssert(array);
  61         this.sortAndAssert(this.floatCopyFromInt(array));
  62         this.sortAndAssert(this.doubleCopyFromInt(array));
  63         this.sortAndAssert(this.longCopyFromInt(array));
  64         this.sortAndAssert(this.shortCopyFromInt(array));
  65         this.sortAndAssert(this.charCopyFromInt(array));

At line 60 should you clone the array? otherwise, if i have looked correctly, that sorted result will be tested for other values.

> * The GS copyright notice from the main JDK patch. However we retain it on our test cases as we developed ourselves. In our previous contributions where we provided new tests we have put our copyright along with oracle copyright and it was accepted (see:

Ok. It was more query on my part. I believe it's ok for you to add copyright on both files if you wish.

> * Alan has commented that there were older benchmark but searching through the archive I can see it mention "BentleyBasher" I cannot find the actual code that Vladimir used (thread: Is there anywhere I can get hold of it?

I tried looking, but i cannot find any.


More information about the core-libs-dev mailing list