Re: [JGIT PATCH 11/12] Cleanup Config's MAGIC_EMPTY_VALUE to be more safe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Robin Rosenberg <robin.rosenberg@xxxxxxxxxx> wrote:
> tisdag 21 juli 2009 22:19:29 skrev "Shawn O. Pearce" <spearce@xxxxxxxxxxx>:
> > The magic value "%%magic%%empty%%" is just too magic; 
...
> > -	private static final String MAGIC_EMPTY_VALUE = "%%magic%%empty%%";
> > +	private static final String MAGIC_EMPTY_VALUE = new StringBuilder(0)
> > +			.toString();
> 
> Can we be sure an implementation doesn't "optimize" toString() here? But an
> explicit new String() shouldn't be..?

*sigh*

I used this form because FindBugs dislikes new String("").  But yea,
at least with new String() we know its a new string object and
there is no pooling of the empty string going on under the covers.

I can't imagine it being a common enough case to convert a
StringBuilder to an empty string that a runtime implementation would
waste instructions over checking for it and reusing a pooled copy,
but eh, yea, maybe this should be new String("") and include a
FindBugs entry to disable the warning here.

-- 
Shawn.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]