Issue 67 in gitsharp: Use String.Equals("") instead of "".Equals(String)

1 view
Skip to first unread message

gits...@googlecode.com

unread,
Jan 1, 2011, 5:45:36 PM1/1/11
to gits...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 67 by dvdvorle: Use String.Equals("") instead of "".Equals(String)
http://code.google.com/p/gitsharp/issues/detail?id=67

In the jgit source i see a lot of the following (for example):
"FETCH_HEAD".equals(ref)

I would like to propose that this be replaced in the GitSharp source with:
ref.Equals("FETCH_HEAD")

Reason:
I think the only gain "".Equals(string_var) has over string_var.Equals("")
is that in some cases you can ommit testing for null, see also the
following answer to a stackoverflow question:
http://stackoverflow.com/questions/1659097/c-string-equals-vs/1660262#1660262

Now some might say this is a matter of personal preference, but I really
think changing the order improves readability. To me, the first version
reads like yoda ("green the grass is.") while the second version reads like
proper english ("the grass is green.")

Reply all
Reply to author
Forward
0 new messages