RFR: 8337457: Redundant Math.round call in AquaProgressBarUI#getStringPlacement

Sergey Bylokhov serb at openjdk.org
Tue Aug 27 22:31:24 UTC 2024


On Wed, 31 Jul 2024 07:12:35 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

> Since  Math.round with integer argument returns the same value, and also since all arguments and calculations in the AquaProgressBarUI#getStringPlacement are integer arithmetic, Math.round is redundant and can be removed

src/java.desktop/macosx/classes/com/apple/laf/AquaProgressBarUI.java line 259:

> 257:         }
> 258: 
> 259:         return new Point(x + (width / 2 - stringWidth / 2), y + ((height + fontSizer.getAscent() - fontSizer.getLeading() - fontSizer.getDescent()) / 2) - 1);

There was the same bug in the BasicProgressBarUI#getStringPlacement, but it seems it was fixed in the opposite way by replacing the "2" ->> "2.0", see https://github.com/openjdk/jdk/commit/338fb4d94a6a66b21ff39fccf541bbfb63251e6c

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20400#discussion_r1733593021


More information about the client-libs-dev mailing list