Skip to content

Commit

Permalink
bridge,css,swing: avoid unnecessary conversions to and from float/double
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosame committed Sep 18, 2023
1 parent 1703c17 commit 03fb72b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public TextPath createTextPath(BridgeContext ctx, Element textPathElement) {
throw new BridgeException(ctx, textPathElement, ERR_ATTRIBUTE_VALUE_MALFORMED,
new Object[] { SVG_START_OFFSET_ATTRIBUTE, s });
}
startOffset = (float) (startOffsetPercent * pathLength / 100.0);
startOffset = startOffsetPercent * pathLength / 100f;

} else {
// its an absolute length
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,34 +241,34 @@ public Value computeValue(CSSStylableElement elt, String pseudo, CSSEngine engin
break;

case 's':
fs = (float) (fs / 1.2);
fs = fs / 1.2f;
break;

case 'l':
fs = (float) (fs * 1.2);
fs = fs * 1.2f;
break;

default: // 'x'
switch (s.charAt(1)) {
case 'x':
switch (s.charAt(3)) {
case 's':
fs = (float) (((fs / 1.2) / 1.2) / 1.2);
fs = fs / (float) (1.2 * 1.2 * 1.2);
break;

default: // 'l'
fs = (float) (fs * 1.2 * 1.2 * 1.2);
fs = fs * (float) (1.2 * 1.2 * 1.2);
}
break;

default: // '-'
switch (s.charAt(2)) {
case 's':
fs = (float) ((fs / 1.2) / 1.2);
fs = fs / (float) (1.2 * 1.2);
break;

default: // 'l'
fs = (float) (fs * 1.2 * 1.2);
fs = fs * (float) (1.2 * 1.2);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1019,8 +1019,8 @@ protected boolean updateRenderingTransform() {
float dx = (float) ((d.width / 2.0f) - pt.getX());
float dy = (float) ((d.height / 2.0f) - pt.getY());
// Round the values to nearest integer.
dx = (int) ((dx < 0) ? (dx - .5) : (dx + .5));
dy = (int) ((dy < 0) ? (dy - .5) : (dy + .5));
dx = (int) ((dx < 0) ? (dx - .5f) : (dx + .5f));
dy = (int) ((dy < 0) ? (dy - .5f) : (dy + .5f));
if ((dx != 0) || (dy != 0)) {
rendAT.preConcatenate(AffineTransform.getTranslateInstance(dx, dy));
setRenderingTransform(rendAT, false);
Expand Down

0 comments on commit 03fb72b

Please sign in to comment.