You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2022/05/03 21:50:21 UTC

[GitHub] [netbeans] mbien commented on a diff in pull request #4059: Cleanup the use of Double primitive wrapper

mbien commented on code in PR #4059:
URL: https://github.com/apache/netbeans/pull/4059#discussion_r864271290


##########
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:
   `(int) (w / chWidth)` would get rid of the temp boxing entirely



##########
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:
   see other comment, of the exact copy of this method



##########
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:
   convert to int cast



##########
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:
   same 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:
   i think `Double.valueOf` can be completely removed here, everything is an int already if i see this correctly.



##########
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:
   same here



##########
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) cast would do the job here too



##########
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:
   ```java
   int width = (int) (jLabelDesc.getFontMetrics(jLabelDesc.getFont()).getStringBounds(jLabelDesc.getText(), getGraphics()).getWidth() / 2.7d) + 40
   ```
   
   would remove temp boxing



##########
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 addition, no need for boxing or a double



##########
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 addition again



##########
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:
   convert to int cast



##########
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:
   -> `(int) ((w - widthPainted) / chWidth)`



##########
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:
   an here



##########
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:
   convert to int cast



##########
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:
   convert to int cast



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists