Bug 230188 - [formatter] Should use StringBuilder instead of StringBuffer in org.eclipse.jdt.internal.formatter.Scribe
Summary: [formatter] Should use StringBuilder instead of StringBuffer in org.eclipse.j...
Status: RESOLVED DUPLICATE of bug 303519
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.8 M2   Edit
Assignee: Mateusz Matela CLA
QA Contact:
URL:
Whiteboard: To be verified for 4.8 M2
Keywords: performance
Depends on:
Blocks:
 
Reported: 2008-05-05 08:00 EDT by Sergey Yevtushenko CLA
Modified: 2017-09-06 03:14 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergey Yevtushenko CLA 2008-05-05 08:00:20 EDT
Build ID: I20080502-0100

Steps To Reproduce:
The Scribe class uses a lot of StringBuffer instances. They can be replaced with StringBuilder without any additional efforts. Since all instances are local variables and are not involved in mutlithreaded interactions, there is no need to use synchronized StringBuffer.

More information:
Comment 1 Olivier Thomann CLA 2008-05-05 08:54:35 EDT
StringBuilder is a 1.5 class and JDT/Core cannot use any classes from 1.5. The EE specified for JDT/Core is 1.4.
Closing as INVALID.
Comment 2 Jerome Lanneluc CLA 2008-05-05 11:28:51 EDT
Setting target milestone to 3.4RC1 as per JDT/Core process
Comment 3 Maxime Daniel CLA 2008-05-13 06:09:30 EDT
Question: how would a JDT backport of StringBuilder fare on a cost/benefit standpoint?
Comment 4 Frederic Fusier CLA 2008-05-13 11:36:04 EDT
I agree that even if StringBuilder is not usable because it's a part of JRE 1.5, we can improve the Scribe to avoid StringBuffer current intensive usage...
Comment 5 Maxime Daniel CLA 2008-05-13 15:25:18 EDT
My point was more along the following: we have utilities in place around char arrays, etc., that focus on speed quite a bit, and were (and still are) somewhat involving in terms of implementation when they were coded. I believe it would not be stretching such a design too much to envision adding a port of StringBuilder to that arsenal, *provided we get some clear benefit from doing so*.
Comment 6 Frederic Fusier CLA 2008-05-13 15:45:47 EDT
In fact that was exactly what I understood of your remark but I took advantage of this bug to remind that some performance improvements could be done in the Scribe (in fact the exact summary of this bug).

IMO, this could be done either by using an internal class as you suggested or a more aggressive way which would avoid to use any temporary buffer by creating edits directly...
Comment 7 Frederic Fusier CLA 2010-12-27 03:50:42 EST
StringBuffer allocations have been strongly reduced while improving formatter performances in 3.6, hence closing this bug as duplicate of bug 310811.

*** This bug has been marked as a duplicate of bug 310811 ***
Comment 8 Satyam Kandula CLA 2011-01-25 07:35:22 EST
The number of StringBuffer creation(s) has been reduced a lot in bug 310811. However, as I understand all the string buffer methods are synchronized and hence they could still be having some performance impact. 
As we will be moving to Java 1.5, I think we should keep this bug open. 

Olivier, comments?
Comment 9 Olivier Thomann CLA 2011-01-25 08:41:26 EST
Once we move to 1.5, we should use StringBuilder instead of StringBuffer.
Satyam, please update the title accordingly.
Comment 10 Satyam Kandula CLA 2011-01-25 09:33:18 EST
Reopening this as we want to move to Java 1.5. When we move to Java 1.5, we could use StringBuilder instead of StringBuffer.
Comment 11 Frederic Fusier CLA 2011-01-31 07:22:10 EST
(In reply to comment #10)
> Reopening this as we want to move to Java 1.5. When we move to Java 1.5, we
> could use StringBuilder instead of StringBuffer.

Satyam, do you expect me to have a look on this when possible?
Comment 12 Satyam Kandula CLA 2011-01-31 07:37:30 EST
Thanks Frederic. I can take care of this when we move to 1.5.
Comment 13 Mateusz Matela CLA 2017-09-06 03:14:46 EDT
This bug is no longer relevant after bug 303519 - the new formatter doesn't use any StringBuffers.

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