diff options
| author | Fabrice Tiercelin | 2021-04-06 10:22:43 +0000 |
|---|---|---|
| committer | Fabrice Tiercelin | 2021-04-06 10:22:43 +0000 |
| commit | 35a405a0d51c437042a55ff10358346519553707 (patch) | |
| tree | 54f9f96aebe144b072dedf8654f2710f049a7965 | |
| parent | b0dee247198def3a1ee172839c694bb5af9fdef9 (diff) | |
| download | news-35a405a0d51c437042a55ff10358346519553707.tar.gz news-35a405a0d51c437042a55ff10358346519553707.tar.xz news-35a405a0d51c437042a55ff10358346519553707.zip | |
Bug 572234 - [AutoRefactor immigration #65/151] [cleanup & saveaction]
valueOf() rather than instantiation
Given:
Byte by = new Byte((byte) 4);
Boolean bo = new Boolean(true);
Character c = new Character('c');
Double d = new Double(1);
Float f1 = new Float(1f);
Float f2 = new Float(1d);
Long l = new Long(1);
Short s = new Short((short) 1);
Integer i = new Integer(1);
new Byte("0").byteValue();
byte by2 = new Byte((byte) 0);
When:
Clean up the code enabling "valueOf() rather than instantiation"
Then:
Byte by = Byte.valueOf((byte) 4);
Boolean bo = Boolean.valueOf(true);
Character c = Character.valueOf('c');
Double d = Double.valueOf(1);
Float f1 = Float.valueOf(1f);
Float f2 = Float.valueOf((float) 1d);
Long l = Long.valueOf(1);
Short s = Short.valueOf((short) 1);
Integer i = Integer.valueOf(1);
Byte.valueOf("0").byteValue();
byte by2 = (byte) 0;
Change-Id: I63a3811a296c7582d74b626398ee0ec7a588b0c4
Signed-off-by: Fabrice Tiercelin <fabrice.tiercelin@yahoo.fr>
Depends-On: I09d22630e415640929f4bbaf5ab291aa88cc884d
| -rw-r--r-- | 4.20/images/valueof-rather-than-instantiation-after.png | bin | 0 -> 23089 bytes | |||
| -rw-r--r-- | 4.20/images/valueof-rather-than-instantiation-before.png | bin | 0 -> 25878 bytes | |||
| -rw-r--r-- | 4.20/images/valueof-rather-than-instantiation-preferences.png | bin | 0 -> 43473 bytes | |||
| -rw-r--r-- | 4.20/jdt.html | 22 |
4 files changed, 22 insertions, 0 deletions
diff --git a/4.20/images/valueof-rather-than-instantiation-after.png b/4.20/images/valueof-rather-than-instantiation-after.png Binary files differnew file mode 100644 index 00000000..a48673f8 --- /dev/null +++ b/4.20/images/valueof-rather-than-instantiation-after.png diff --git a/4.20/images/valueof-rather-than-instantiation-before.png b/4.20/images/valueof-rather-than-instantiation-before.png Binary files differnew file mode 100644 index 00000000..f80b9e99 --- /dev/null +++ b/4.20/images/valueof-rather-than-instantiation-before.png diff --git a/4.20/images/valueof-rather-than-instantiation-preferences.png b/4.20/images/valueof-rather-than-instantiation-preferences.png Binary files differnew file mode 100644 index 00000000..42a053b9 --- /dev/null +++ b/4.20/images/valueof-rather-than-instantiation-preferences.png diff --git a/4.20/jdt.html b/4.20/jdt.html index 587953a4..5a39e1e3 100644 --- a/4.20/jdt.html +++ b/4.20/jdt.html @@ -117,6 +117,28 @@ ul {padding-left: 13px;} </td> </tr> + <tr id="valueof-rather-than-instantiation"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=572234 --> + <td class="title"><a href="#valueof-rather-than-instantiation">valueOf() rather than instantiation clean up</a></td> + <td class="content"> + A new clean up has been added that replaces unnecessary primitive wrappers instance creations by using static factory methods (<code>valueOf()</code>). + <p> + It dramatically improves the space performance. + </p> + <p> + To apply the clean up, select <b>valueOf() rather than instantiation</b> check box on the <b>Optimization</b> tab in your clean up profile. + </p> + <p><img src="images/valueof-rather-than-instantiation-preferences.png" alt="Preferences" width="800"/></p> + <p> + For the given code: + </p> + <p><img src="images/valueof-rather-than-instantiation-before.png" alt="Before"/></p> + <p> + One gets: + </p> + <p><img src="images/valueof-rather-than-instantiation-after.png" alt="After"/></p> + </td> + </tr> + <tr id="array-with-curly"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=571977 --> <td class="title"><a href="#array-with-curly">Initialize array with curly clean up</a></td> <td class="content"> |
