sdowsland / google-diff-match-patch

Automatically exported from code.google.com/p/google-diff-match-patch
Apache License 2.0
0 stars 0 forks source link

Improve Java-Code #58

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I have prepeared a patch which includes some improvements in Java Code.

Original issue reported on code.google.com by jweberho...@weberhofer.at on 8 Nov 2011 at 3:13

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by neil.fra...@gmail.com on 9 Nov 2011 at 9:36

GoogleCodeExporter commented 9 years ago
With respect to the "Garbage collect" line, we've had long discussions about 
that.  Although lint tools will point at that line and scream, it actually does 
serve a useful purpose by telling the garbage collector that those two 
(potentially large) variables can be reclaimed.  This is beneficial given the 
memory-intensive diffing that is to come.

The 'i' variable in diff_prettyHtml is indeed orphaned code.  I've removed it 
from all seven languages.  Good catch.

The 'nullPadding' variable in patch_addPadding has also generated long 
discussions.  This string is only four characters long.  It is faster to build 
it with string concatenation than it is to instantiate a StringBuffer object 
and repeatedly call functions on it.

Regarding blank lines between methods, Java's style guide does say to use only 
one blank line between methods, so I've removed all the double spaces.

Thanks for the hashCode and equals functions.  I've simplified the former a bit.

All changes checked into Subversion.

Original comment by neil.fra...@gmail.com on 10 Nov 2011 at 6:54