|
From: | Archie Cobbs |
Subject: | Re: [cp-patches] Patch: convert new Boolean(X) to Boolean.valueOf(X) |
Date: | Wed, 14 Sep 2005 18:40:51 -0500 |
User-agent: | Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.3) Gecko/20041129 |
David Daney wrote:
Archie Cobbs wrote:Mark Wielaard wrote:While messing around with FindBugs, I came up with the following useful patch. It converts all "new Boolean(X)" instances to "Boolean.valueOf(X)". Ok? [...] - return new Boolean(true); + return Boolean.valueOf(true);OK, but if you know the actual value then using Boolean.TRUE and Boolean.FALSE seems more appropriate then valueOf(). Could you make that change?That shouldn't be necessary .. the method inliner will likely take care of that (Boolean.valueOf() is guaranteed to return either Boolean.TRUE or Boolean.FALSE) so the ultimate effect should be the same.None of this is necessary. But we do it anyway to make the code better.For me Boolean.TRUE reads much more cleanly than Boolean.valueOf(true). I think it improbable that it is less efficient either.
Apologies, I didn't see that you were referring to the specific patch chunk that used the literal constant "true".. I completely agree with you in that case! All I meant to say is that "Boolean.valueOf(x)" is not worse than "x ? Boolean.TRUE : Boolean.FALSE". -Archie __________________________________________________________________________ Archie Cobbs * CTO, Awarix * http://www.awarix.com
[Prev in Thread] | Current Thread | [Next in Thread] |