This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 189409 - Performance/String concatenation in StringBuilder.append
Summary: Performance/String concatenation in StringBuilder.append
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 6.x
Hardware: PC Windows Vista
: P3 normal with 1 vote (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-11 16:49 UTC by culli
Modified: 2013-09-02 14:19 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description culli 2010-08-11 16:49:20 UTC
This hint catches:
String test = "blah";
StringBuilder builder = new StringBuilder();
builder.append("blah"+test);

but does not catch:
String test = "blah";
StringBuilder builder = new StringBuilder();
builder.append("blah"+"blah");



If you have code that has:

String blarg = 
"blah blah blah" +
" blah blah blah" +
" blah blah blah" +
" blah blah blah" +;

it would be nice if netbeans could auto-convert that to:

StringBuilder builder = new StringBuilder();
builder.append("blah blah blah");
builder.append(" blah blah blah");
builder.append(" blah blah blah");
builder.append(" blah blah blah");
String blarg = builder.toString();

Or convert to chained .append would work, but not as cleanly in my opinion.  

I would guess that the java compiler converts the concatenation of string literals into one big string in bytecode, but when you have a giant string like that and you're working to refactor the code around it, it would be nice if netbeans had an auto-convert to StringBuilder.