Skip to content

Conversation

@turbanoff
Copy link

@turbanoff turbanoff commented Nov 26, 2024

StringBuffer is a legacy synchronized class. StringBuilder is a direct replacement to StringBuffer which generally have better performance. It's quite important for performance in fresh versions of Java which disabled/removed biased locking.

mvn verify

[INFO] Reactor Summary for xalan-j 2.7.3:
[INFO]
[INFO] xalan-j ............................................ SUCCESS [  7.420 s]
[INFO] @xsl.usage taglet JDK9+ ............................ SUCCESS [  2.443 s]
[INFO] Apache XML Serializer .............................. SUCCESS [  8.457 s]
[INFO] Apache Xalan-Java .................................. SUCCESS [ 13.493 s]
[INFO] Apache Xalan-Java Samples .......................... SUCCESS [  1.630 s]
[INFO] Apache Xalan-Java Servlet Sample ................... SUCCESS [  1.972 s]
[INFO] Apache Xalan-Java Applet Sample .................... SUCCESS [  1.223 s]
[INFO] Apache Xalan-Java Brazil Sample .................... SUCCESS [  1.036 s]
[INFO] Apache Xalan-Java XSLTC EJB sample ................. SUCCESS [  1.127 s]
[INFO] Apache Xalan-Java Compiled Servlet Sample .......... SUCCESS [  1.062 s]
[INFO] distribution ....................................... SUCCESS [  3.989 s]
[INFO] integration-tests .................................. SUCCESS [ 10.612 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  54.606 s
[INFO] Finished at: 2024-11-26T10:03:43+03:00

StringBuffer is a legacy synchronized class. StringBuilder is a direct replacement to StringBuffer which generally have better performance.
It's quite important for performance in fresh versions of Java which disabled/removed biased locking.
Copy link

@elharo elharo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR might be correct, but FYI StringBuilder is not a direct replacement for StringBuffer. It's fine for local variables that don't escape method scope. Other usages need careful consideration of whether the synchronization properties are important.

private StringBuilder getListOfEnums()
{
StringBuffer enumNamesList = new StringBuffer();
StringBuilder enumNamesList = new StringBuilder();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation looks off by one space


public static void printUsage() {
StringBuffer vers = new StringBuffer("XSLTC version " + VERSION_MAJOR
StringBuilder vers = new StringBuilder("XSLTC version " + VERSION_MAJOR
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one's weird. It should probably just use a String, or maybe use append, but really a String is all that's needed; neither StringBuilder nor StringBuffer is appropriate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants