DESCRIPTION

Bug 470233 - Replace new Boolean with Boolean.valueOf

Using `new Boolean()` results in the creation of a new object on the
heap, when the flyweight `Boolean.TRUE` and `Boolean.FALSE` are available.
Java 1.4 added a `Boolean.valueOf()` which can be used in place of
`new Boolean()` but which will use the existing flyweight values instead.

Globally change `new Boolean(...)` to `Boolean.valueOf(...)` and replace
constant valued expressions with their flyweight counterparts.

Bug: 470233
Change-Id: I06be411c8e2ef387275af06409996acdab7c2cf3
Signed-off-by: Blake Oneal xxx@xxx.xxx


COMMENTS

author: Blake Oneal
date: 2015-06-16 07:55:44.000000000

Uploaded patch set 1.

-------------------------------------
author: Brenden Conley
date: 2015-06-16 07:55:50.000000000

Patch Set 1:

Build Started https://hudson.eclipse.org/platform/job/eclipse.platform.ui-Gerrit/5862/

-------------------------------------
author: Brenden Conley
date: 2015-06-16 08:08:23.000000000

Patch Set 1: Verified+1

Build Successful 

https://hudson.eclipse.org/platform/job/eclipse.platform.ui-Gerrit/5862/ : SUCCESS

-------------------------------------
author: Blake Oneal
date: 2015-06-16 08:29:10.000000000

Patch Set 1: Code-Review+1

I'm happy with this change - both new Boolean(String) and Boolean.valueOf(String) delegate to parseBoolean(String) to acquire the boolean value. There's a further slight optimisation where there's a Boolean.valueOf(thing).booleanValue() which could be replaced directly with a Boolean.parseValue() though.

-------------------------------------
author: Blake Oneal
date: 2015-06-16 08:35:31.000000000

Patch Set 1:

(1 comment)

Added the place where Boolean.valueOf().booleanValue() is called. We don't generate any heap noise here now and the JIT could in-line if needed.

Line:443, bundles/org.eclipse.ui.workLeon Ochoach/Eclipse UI/org/eclipse/ui/internal/registry/EditorDescriptor.java -> This could be replaced with Boolean.parseBoolean(...) instead, since we're just getting the boolean value. However it's in a legacy pre-3.0 RCP method so I'm not sure it's worth it?

-------------------------------------
author: Teagan Marsh
date: 2015-06-29 00:56:08.000000000

Patch Set 1:

(1 comment)

Line:443, bundles/org.eclipse.ui.workLeon Ochoach/Eclipse UI/org/eclipse/ui/internal/registry/EditorDescriptor.java -> Hmm, is there a reason we shouldn't just use Memento#getBoolean() instead?

-------------------------------------
