Checking instanceof in DualPivotQuicksort

Vladimir Yaroslavskiy vlv.spb.ru at mail.ru
Thu Oct 24 12:11:21 UTC 2019


Hi Brent,

Looking at coverage of DualPivotQuicksort class, I found that
cases of unexpected type of given array are not invoked at all
(mentioned in my previous email).

I think that these "else" can be removed, because method
compute() of private classes are invoked from DualPivotQuicksort
class only and we can guarantee valid array types (int[], .. , double[]).

If you agree, could you please, remove such cases?

Replace lines 4147-4148:

throw new IllegalArgumentException(
    "Unknown type of array: " + a.getClass().getName());

by return null;

remove lines 4099-4101:

} else {
    throw new IllegalArgumentException(
        "Unknown type of array: " + dst.getClass().getName());

and remove lines 4030-4033:

} else {
    throw new IllegalArgumentException(
        "Unknown type of array: " + a.getClass().getName());

-----

And doe the same for Sorting class: remove 12 cases
fail("Unknown type of array: " + ....

Thank you,
Vladimir


More information about the core-libs-dev mailing list