Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 328354 - Suggest use of StringBuilder instead of StringBuffer where appropriate
Summary: Suggest use of StringBuilder instead of StringBuffer where appropriate
Status: CLOSED DUPLICATE of bug 128020
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-21 10:09 EDT by Alex Blewitt CLA
Modified: 2010-10-22 03:10 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Blewitt CLA 2010-10-21 10:09:16 EDT
Build Identifier: 3.7

Code that is of the form:
public String foo() {
  StringBuffer buffer = new StringBuffer();
  buffer.append("stuff");
  return buffer.toString()
}

can be promoted to StringBuilder (if the compiler compliance is >= 1.5) without any loss of function. An informational/warning dialog noting the construction and destruction of a StringBuffer inside a single method (i.e. does not escape through field, inner class binding etc.) is guaranteed to be handled by a single thread and so can use the StringBuilder which doesn't have synchronized semantics.

Reproducible: Always
Comment 1 Dani Megert CLA 2010-10-22 03:10:26 EDT

*** This bug has been marked as a duplicate of bug 128020 ***