Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 2.9.1
-
Component/s: Runtime: Class Library
-
Labels:None
-
Environment:All
-
Number of attachments :
Description
In Arrays.qsort the methods Float.compare and Double.compare are used depending on the values in the array. The compare operations perform the following (copied from GNU Classpath):
if (isNaN
)
return isNaN
? 0 : 1;
if (isNaN
)
return -1;
// recall that 0.0 == -0.0, so we convert to infinites and try again
if (x == 0 && y == 0)
return (int) (1 / x - 1 / y);
if (x == y)
return 0;
return x > y ? 1 : -1;
In the normal case we're going to hit 6 floating point compares. The case of 0, 0 is common due to using qsort on branch profiles, and this results in 2 divides and 1 subtract. Given we're just comparing to values we should be able to do this substantially cheaper in a VM specific/magic version.
Activity
Ian Rogers
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Assignee | Ian Rogers [ ianrogers ] |
Ian Rogers
made changes -
| Fix Version/s | 2.9.1 [ 13529 ] | |
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Resolution | Fixed [ 1 ] |
David Grove
made changes -
| Status | Resolved [ 5 ] | Closed [ 6 ] |