RFR: 8185757: QuickSort array size should be size_t
Kim Barrett
kim.barrett at oracle.com
Wed Aug 2 23:29:37 UTC 2017
Please review this change of the type of QuickSort::sort size
parameter from int to size_t, and propogating this change throughout
the QuickSort implementation (using size_t rather than int sizes and
indices) and tests.
Since I was touching the QuickSort code anyway, I made a couple of
additional changes.
- Re-ordered the internal template parameters, moving "idempotent" to
the front and allowing the array element type and the comparator type
to be deduced.
- Changed the handling of the result of calling the comparator, only
requiring it to return negative, zero, or positive, rather than
exactly -1, 0, or +1. This makes it consistent with the standard
library function qsort.
Also updated a couple of callers:
- In G1CollectionSet::finalize_old_part, removed no longer needed cast
of (size_t) size to int.
- In Method::sort_methods, removed unnecessary explicit template
argument, allowing it to be deduced. I didn't change the length from
int to size_t here, because that had more fanout, and there are other
issues around its type. For example, it is being passed to other
functions that expect a u2 value.
CR:
https://bugs.openjdk.java.net/browse/JDK-8185757
Webrev:
http://cr.openjdk.java.net/~kbarrett/8185757/hotspot.00/
Testing:
JPRT. In addition to unit testing, sorting gets exercised by G1 and by
class file parsing (sort_methods).
More information about the hotspot-runtime-dev
mailing list