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/01 04:58:38 UTC

[GitHub] [netbeans] BradWalker opened a new pull request, #4059: Cleanup the use of Double primitive wrapper

BradWalker opened a new pull request, #4059:
URL: https://github.com/apache/netbeans/pull/4059

   As of Java 9, the VM can do a better job of handling the conversion from a Double primitive to a Double Object or vice versa.
   
   This is an extension of the work done in #2498.
   
   No tests have been touched as those expressly need to manage the conversion.
   
   A couple of places I also cleaned up the Float.
   
   
   
   
   
   ---
   **^Add meaningful description above**
   
   By opening a pull request you confirm that, unless explicitly stated otherwise, the changes -
   
    - are all your own work, and you have the right to contribute them.
    - are contributed solely under the terms and conditions of the Apache License 2.0 (see section 5 of the license for more information).
   
   Please make sure (eg. `git log`) that all commits have a valid name and email address for you in the Author field.
   
   If you're a first time contributor, see the Contributing guidelines for more information.
   
   


-- 
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


[GitHub] [netbeans] neilcsmith-net closed pull request #4059: Cleanup the use of Double primitive wrapper

Posted by GitBox <gi...@apache.org>.
neilcsmith-net closed pull request #4059: Cleanup the use of Double primitive wrapper
URL: https://github.com/apache/netbeans/pull/4059


-- 
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


[GitHub] [netbeans] neilcsmith-net commented on pull request #4059: Cleanup the use of Double primitive wrapper

Posted by GitBox <gi...@apache.org>.
neilcsmith-net commented on PR #4059:
URL: https://github.com/apache/netbeans/pull/4059#issuecomment-1185624278

   Given we're close to freeze, let's punt this to NB16.


-- 
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


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

Posted by GitBox <gi...@apache.org>.
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


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

Posted by GitBox <gi...@apache.org>.
mbien commented on code in PR #4059:
URL: https://github.com/apache/netbeans/pull/4059#discussion_r864282087


##########
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:
   and 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: 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


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

Posted by GitBox <gi...@apache.org>.
mbien commented on PR #4059:
URL: https://github.com/apache/netbeans/pull/4059#issuecomment-1173007302

   @BradWalker say if you need help with this one


-- 
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


[GitHub] [netbeans] neilcsmith-net commented on pull request #4059: Cleanup the use of Double primitive wrapper

Posted by GitBox <gi...@apache.org>.
neilcsmith-net commented on PR #4059:
URL: https://github.com/apache/netbeans/pull/4059#issuecomment-1274631904

   Given we're now close to NB16 freeze and there's been no further movement on this, going to close.  Re-open if necessary.


-- 
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