mbien commented on code in PR #5714:
URL: https://github.com/apache/netbeans/pull/5714#discussion_r1154103629
##########
ide/editor.completion/src/org/netbeans/modules/editor/completion/PatchedHtmlRenderer.java:
##########
@@ -841,7 +841,7 @@ If NO (it's a closing tag)
//Word wrap mode
goToNextRow = true;
- int lastChar = new Double(nextTag -
estCharsOver).intValue();
+ int lastChar = Double.valueOf(nextTag -
estCharsOver).intValue();
Review Comment:
int minus double, result (double) is cast to int
->
`(int) (nextTag - estCharsOver)`
##########
enterprise/javaee.project/src/org/netbeans/modules/javaee/project/api/ant/ui/wizard/ImportBuildfile.java:
##########
@@ -52,7 +52,7 @@ public ImportBuildfile(File buildFile, JButton okButton) {
}
private void resize() {
- int width = (new
Double(jLabelDesc.getFontMetrics(jLabelDesc.getFont()).getStringBounds(jLabelDesc.getText(),
getGraphics()).getWidth() / 2.7)).intValue() + 40;
+ int width =
Double.valueOf(jLabelDesc.getFontMetrics(jLabelDesc.getFont()).getStringBounds(jLabelDesc.getText(),
getGraphics()).getWidth() / 2.7).intValue() + 40;
Review Comment:
this can be changed to:
```java
int width = (int)
(jLabelDesc.getFontMetrics(jLabelDesc.getFont()).getStringBounds(jLabelDesc.getText(),
getGraphics()).getWidth() / 2.7d) + 40;
```
##########
ide/editor.completion/src/org/netbeans/modules/editor/completion/PatchedHtmlRenderer.java:
##########
@@ -911,7 +911,7 @@ If NO (it's a closing tag)
if (strikethrough || underline) {
LineMetrics lm = fm.getLineMetrics(chars, pos, length
- 1, g);
- int lineWidth = new Double(x +
r.getWidth()).intValue();
+ int lineWidth = Double.valueOf(x +
r.getWidth()).intValue();
Review Comment:
simple int + double addition with int cast ->
`(int) (x + r.getWidth())`
##########
ide/editor.completion/src/org/netbeans/modules/editor/completion/PatchedHtmlRenderer.java:
##########
@@ -892,7 +892,7 @@ If NO (it's a closing tag)
}
} else if (brutalWrap) {
//wrap without checking word boundaries
- length = (new Double((w - widthPainted) /
chWidth)).intValue();
+ length = Double.valueOf((w - widthPainted) /
chWidth).intValue();
Review Comment:
again, chWidth is a double ->
`(int) ((w - widthPainted) / chWidth))`
##########
platform/o.n.swing.tabcontrol/src/org/netbeans/swing/tabcontrol/plaf/BaseTabLayoutModel.java:
##########
@@ -123,7 +123,7 @@ protected int textHeight(int index, JComponent component) {
//No need to calculate for every string
String testStr = "Zgj"; //NOI18N
Font f = getFont();
- textHeight = new Double(f.getStringBounds(testStr,
+ textHeight = Double.valueOf(f.getStringBounds(testStr,
BasicScrollingTabDisplayerUI.getOffscreenGraphics(component).getFontRenderContext()).getWidth()).intValue()
+ 2;
Review Comment:
simple int cast again
##########
java/form/src/org/netbeans/modules/form/layoutdesign/LayoutDesigner.java:
##########
@@ -465,8 +465,8 @@ public void startMoving(String[] compIds, Rectangle[]
bounds, Point hotspot) {
testCode.add("{"); //NOI18N
LayoutTestUtils.writeStringArray(testCode, "compIds", compIds);
//NOI18N
LayoutTestUtils.writeRectangleArray(testCode, "bounds", bounds);
//NOI18N
- testCode.add("Point hotspot = new Point(" + new
Double(hotspot.getX()).intValue() + "," + //NOI18N
- new Double(hotspot.getY()).intValue() + ");"); //NOI18N
+ testCode.add("Point hotspot = new Point(" +
Double.valueOf(hotspot.getX()).intValue() + "," + //NOI18N
+ Double.valueOf(hotspot.getY()).intValue() + ");"); //NOI18N
Review Comment:
int casts
##########
java/form/src/org/netbeans/modules/form/layoutdesign/LayoutDesigner.java:
##########
@@ -437,8 +437,8 @@ public void startAdding(LayoutComponent[] comps,
LayoutTestUtils.writeLayoutComponentArray(testCode, "comps",
"lc"); //NOI18N
LayoutTestUtils.writeRectangleArray(testCode, "bounds", bounds);
//NOI18N
LayoutTestUtils.writeString(testCode, "defaultContId",
defaultContId); //NOI18N
- testCode.add("Point hotspot = new Point(" + new
Double(hotspot.getX()).intValue() + "," + //NOI18N
- new Double(hotspot.getY()).intValue() + ");");
//NOI18N
+ testCode.add("Point hotspot = new Point(" +
Double.valueOf(hotspot.getX()).intValue() + "," + //NOI18N
+ Double.valueOf(hotspot.getY()).intValue() + ");");
//NOI18N
Review Comment:
int casts
##########
platform/openide.awt/src/org/openide/awt/HtmlRenderer.java:
##########
@@ -1127,7 +1127,7 @@ If NO (it's a closing tag)
if (strikethrough || underline || link) {
LineMetrics lm = fm.getLineMetrics(chars, pos, length
- 1, g);
- int lineWidth = new Double(x +
r.getWidth()).intValue();
+ int lineWidth = Double.valueOf(x +
r.getWidth()).intValue();
Review Comment:
and again
##########
profiler/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/ClassesListController.java:
##########
@@ -164,8 +164,7 @@ public Object[][] getData(String[] filterStrings, int
filterType, boolean showZe
else data[i][4] = (retainedSizeByClass > 0 ? "+" : "") +
numberFormat.format(retainedSizeByClass); // NOI18N
}
} else {
- data[i][1] = new Double((double) instancesCount /
- (double) totalLiveInstances * 100);
+ data[i][1] = (double)instancesCount / totalLiveInstances * 100;
Review Comment:
you can drop the double if you want. right hand side is double, which means
the result is a double
##########
ide/editor.completion/src/org/netbeans/modules/editor/completion/PatchedHtmlRenderer.java:
##########
@@ -176,7 +176,7 @@ private static double _renderPlainString(
}
double chWidth = wid / chars.length;
- int estCharsToPaint = new Double(w / chWidth).intValue();
+ int estCharsToPaint = Double.valueOf(w / chWidth).intValue();
Review Comment:
this is int divided by double and the result (double) is casted down to int.
please change to
`(int) (w / chWidth)`
which is the equivalent
Double#intValue is implemented as:
```java
public int intValue() {
return (int)value;
}
```
so we are essentially inlining a method here.
##########
ide/db/src/org/netbeans/modules/db/explorer/dlg/CreateTableDialog.java:
##########
@@ -471,7 +471,7 @@ public DataTable(TableModel model) {
Map cmap = ColumnItem.getColumnProperty(i);
col.setIdentifier(cmap.get("name")); //NOI18N
columnName = NbBundle.getMessage (CreateTableDialog.class,
"CreateTable_" + i); //NOI18N
- columnWidth = (new
Double(getFontMetrics(getFont()).getStringBounds(columnName,
getGraphics()).getWidth())).intValue() + 20;
+ columnWidth =
Double.valueOf(getFontMetrics(getFont()).getStringBounds(columnName,
getGraphics()).getWidth()).intValue() + 20;
Review Comment:
this code is fairly harmless and is only calculating a column width for UI.
Should be save to change like @matthiasblaesing suggested.
its essentially the width of a Rectangle2D, casted down to int + 20, thats
it.
##########
java/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/wizards/ImportFoldersPanel.java:
##########
@@ -86,7 +86,7 @@ private void updateDistFolder() {
}
private void resize() {
- int width = (new
Double(message.getFontMetrics(message.getFont()).getStringBounds(message.getText(),
getGraphics()).getWidth() / 2.7)).intValue() + 40;
+ int width =
Double.valueOf(message.getFontMetrics(message.getFont()).getStringBounds(message.getText(),
getGraphics()).getWidth() / 2.7).intValue() + 40;
Review Comment:
we had that pattern once before
##########
platform/openide.awt/src/org/openide/awt/HtmlRenderer.java:
##########
@@ -1057,7 +1057,7 @@ If NO (it's a closing tag)
//Word wrap mode
goToNextRow = true;
- int lastChar = new Double(nextTag -
estCharsOver).intValue();
+ int lastChar = Double.valueOf(nextTag -
estCharsOver).intValue();
Review Comment:
same here
##########
java/form/src/org/netbeans/modules/form/layoutdesign/LayoutDesigner.java:
##########
@@ -519,8 +519,8 @@ public boolean startResizing(String[] compIds,
testCode.add("{"); //NOI18N
LayoutTestUtils.writeStringArray(testCode, "compIds", compIds);
//NOI18N
LayoutTestUtils.writeRectangleArray(testCode, "bounds", bounds);
//NOI18N
- testCode.add("Point hotspot = new Point(" + new
Double(hotspot.getX()).intValue() + "," + //NOI18N
- new Double(hotspot.getY()).intValue() + ");"); //NOI18N
+ testCode.add("Point hotspot = new Point(" +
Double.valueOf(hotspot.getX()).intValue() + "," + //NOI18N
+ Double.valueOf(hotspot.getY()).intValue() + ");"); //NOI18N
Review Comment:
int cast again
##########
platform/openide.awt/src/org/openide/awt/HtmlRenderer.java:
##########
@@ -1108,7 +1108,7 @@ If NO (it's a closing tag)
}
} else if (brutalWrap) {
//wrap without checking word boundaries
- length = (new Double((w - widthPainted) /
chWidth)).intValue();
+ length = Double.valueOf((w - widthPainted) /
chWidth).intValue();
Review Comment:
int cast again
##########
platform/openide.awt/src/org/openide/awt/HtmlRenderer.java:
##########
@@ -352,7 +352,7 @@ private static double _renderPlainString(
}
double chWidth = wid / chars.length;
- int estCharsToPaint = new Double(w / chWidth).intValue();
+ int estCharsToPaint = Double.valueOf(w / chWidth).intValue();
Review Comment:
same here
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists