RFR: 8337268: Redundant Math.ceil in StyleSheet.ListPainter#drawShape

Alisen Chung achung at openjdk.org
Fri Jul 26 17:03:33 UTC 2024


On Fri, 26 Jul 2024 16:45:31 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

> Math.ceil call with integer argument is redundant as it returns the same value without Math.ceil, so it is removed..
> CI testing is green and JDK-8202013 regression testcase for which the code was added, is not affected..

src/java.desktop/share/classes/javax/swing/text/html/StyleSheet.java line 2394:

> 2392:             int gap = isLeftToRight ? - (bulletgap + size/3) : (aw + bulletgap);
> 2393:             int x = ax + gap;
> 2394:             int y = Math.max(ay, ay + ah/2);

Rather than redundant, wasn't this code just incorrect? For example int 3/2 is 1 and ceiling that after is still 1, but I assume that the original purpose of the code was to make ceil(3/2)=2? Should this be fixed to divide as a float then ceil it afterwards?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/20358#discussion_r1693355098


More information about the client-libs-dev mailing list