Issue Details (XML | Word | Printable)

Key: NUCCORE-554
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Unassigned
Reporter: Fernando Padilla
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
DataNucleus Core

OIDImpl, OIDImplKodo use StringBuffer within constructor, instead of StringBuilder

Created: 27/Jul/10 08:44 AM   Updated: 20/Oct/10 09:29 AM   Resolved: 20/Sep/10 12:54 PM
Component/s: None
Affects Version/s: None
Fix Version/s: 2.2.0.m2


 Description  « Hide
As you know, the difference between StringBuffer and StringBuilder is that StringBuffer is implicitly synchronized. But within the OIDImpl constructor, it's not multithreaded, so it's just wasted overhead.

BEFORE:
        StringBuffer s = new StringBuffer();
        s.append(this.pcClass);
        s.append(oidSeparator);
        s.append(this.oid.toString());

AFTER:
StringBuilder s = new StringBuilder();
...


----

And actually, for pre-determined appends like this, using a StringBuffer/Builder doesn't really make a difference from the "+" operator, so you can make the code more legible by simply concatenating the values directly:

String s = this.pcClass + oidSeparator + this.oid;


Sort Order: Ascending order - Click to sort in descending order
Andy Jefferson added a comment - 20/Sep/10 12:54 PM
Those particular instances are changed, but then it is a more general issue than that since DN was written originally for JDK1.3+ so used StringBuffer in many places.