Bug 21869 - We should to use StringBuilder instead of StringBuffer where appropriate.
Summary: We should to use StringBuilder instead of StringBuffer where appropriate.
Status: RESOLVED FIXED
Alias: None
Product: classpath
Classification: Unclassified
Component: classpath (show other bugs)
Version: 0.17
: P2 enhancement
Target Milestone: 0.98
Assignee: Andrew John Hughes
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-01 23:24 UTC by David Daney
Modified: 2008-05-07 18:10 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-02-27 23:00:53


Attachments
Patch to add CPStringBuilder (7.83 KB, patch)
2008-03-01 09:14 UTC, Andrew John Hughes
Details | Diff
Move towards a CPStringBuilder-using code base (15.47 KB, patch)
2008-03-05 21:03 UTC, Andrew John Hughes
Details | Diff
Move towards a CPStringBuilder-using code base (18.20 KB, patch)
2008-03-05 21:03 UTC, Andrew John Hughes
Details | Diff
Move towards a CPStringBuilder-using code base (316 bytes, patch)
2008-03-05 21:04 UTC, Andrew John Hughes
Details | Diff
Move towards a CPStringBuilder-using code base (4.43 KB, patch)
2008-03-16 22:29 UTC, Andrew John Hughes
Details | Diff
Move towards a CPStringBuilder-using code base (3.85 KB, patch)
2008-03-16 22:45 UTC, Andrew John Hughes
Details | Diff
Move towards a CPStringBuilder-using code base (1.80 KB, patch)
2008-03-16 23:37 UTC, Andrew John Hughes
Details | Diff
Abstract reflection elements of CPStringBuilder to a VM class (2.14 KB, patch)
2008-03-17 00:37 UTC, Andrew John Hughes
Details | Diff
Move towards a CPStringBuilder-using code base (2.97 KB, patch)
2008-03-17 01:30 UTC, Andrew John Hughes
Details | Diff
Fix substring bug (946 bytes, patch)
2008-04-27 22:01 UTC, Andrew John Hughes
Details | Diff
Move towards a CPStringBuilder-using code base (1.85 KB, patch)
2008-05-01 00:44 UTC, Andrew John Hughes
Details | Diff
Move towards a CPStringBuilder-using code base (1.40 KB, patch)
2008-05-01 00:44 UTC, Andrew John Hughes
Details | Diff
Use StringBuilder in the examples (1023 bytes, patch)
2008-05-01 00:45 UTC, Andrew John Hughes
Details | Diff
Move towards a CPStringBuilder-using code base (2.83 KB, patch)
2008-05-07 17:54 UTC, Andrew John Hughes
Details | Diff
Move towards a CPStringBuilder-using code base (1.65 KB, patch)
2008-05-07 17:55 UTC, Andrew John Hughes
Details | Diff
Move towards a CPStringBuilder-using code base (1.36 KB, patch)
2008-05-07 17:56 UTC, Andrew John Hughes
Details | Diff
Move towards a CPStringBuilder-using code base (2.47 KB, patch)
2008-05-07 17:56 UTC, Andrew John Hughes
Details | Diff
Move towards a CPStringBuilder-using code base (1.66 KB, patch)
2008-05-07 17:57 UTC, Andrew John Hughes
Details | Diff
Move towards a CPStringBuilder-using code base (4.36 KB, patch)
2008-05-07 17:57 UTC, Andrew John Hughes
Details | Diff
Move towards a CPStringBuilder-using code base (2.71 KB, patch)
2008-05-07 17:58 UTC, Andrew John Hughes
Details | Diff
Move towards a CPStringBuilder-using code base (3.59 KB, patch)
2008-05-07 17:58 UTC, Andrew John Hughes
Details | Diff
Move towards a CPStringBuilder-using code base (1.35 KB, patch)
2008-05-07 18:01 UTC, Andrew John Hughes
Details | Diff
Move towards a CPStringBuilder-using code base (1.73 KB, patch)
2008-05-07 18:02 UTC, Andrew John Hughes
Details | Diff
Move towards a CPStringBuilder-using code base (2.53 KB, patch)
2008-05-07 18:02 UTC, Andrew John Hughes
Details | Diff
Move towards a CPStringBuilder-using code base (2.81 KB, patch)
2008-05-07 18:03 UTC, Andrew John Hughes
Details | Diff
Move towards a CPStringBuilder-using code base (1.98 KB, patch)
2008-05-07 18:04 UTC, Andrew John Hughes
Details | Diff
Move towards a CPStringBuilder-using code base (2.37 KB, patch)
2008-05-07 18:04 UTC, Andrew John Hughes
Details | Diff
Move towards a CPStringBuilder-using code base (2.93 KB, patch)
2008-05-07 18:07 UTC, Andrew John Hughes
Details | Diff
Move towards a CPStringBuilder-using code base (3.17 KB, patch)
2008-05-07 18:07 UTC, Andrew John Hughes
Details | Diff
Move towards a CPStringBuilder-using code base (4.44 KB, patch)
2008-05-07 18:08 UTC, Andrew John Hughes
Details | Diff
Change tools to use StringBuilder (2.07 KB, patch)
2008-05-07 18:08 UTC, Andrew John Hughes
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Daney 2005-06-01 23:24:46 UTC
Libgcj now has the StringBuilder class which should be used in place of
StringBuffer in places where synchronization is not needed.  All of libgcj
should be changed to use StringBuilder where appropriate.
Comment 1 Tom Tromey 2005-06-02 04:59:57 UTC
See the follow-on discussion on java-patches.
StringBuilder requires a copy of the data;
gnu.gcj.runtime.StringBuffer does not.  The latter could
be made vm-independent and used throughout Classpath.

The thread is here:
http://gcc.gnu.org/ml/java-patches/2005-q2/msg00606.html
Comment 2 Tom Tromey 2005-07-27 17:39:33 UTC
This is a request for Classpath.
Comment 3 Andrew John Hughes 2007-10-09 18:42:08 UTC
Is this still a valid thing to do?  We have an associated JikesRVM task for it:

http://jira.codehaus.org/browse/RVM-266
Comment 4 Ian Rogers 2008-02-07 12:10:09 UTC
There are two improvements described here:

1) avoid synchronization by the use of StringBuilder rather than StringBuffer

this is some what trivial and has largely been carried out in the Classpath code base

2) switch to using a GCJ style string buffer that avoids copies

this is still awaiting action
Comment 5 Andrew John Hughes 2008-02-17 15:57:58 UTC
Waiting on my patch to abstract StringBuffer/Builder being committed.
Then this is simply a matter of adding a class which uses the 'dont_copy' version of the String constructor with toString.
Comment 6 Andrew John Hughes 2008-02-27 23:00:53 UTC
The new structure is committed.  As StringBuilder is final, we will have to clone AbstractStringBuilder in the gnu.classpath package.  This is not too problematic, as we don't expect the internal class to need to change.
Comment 7 Andrew John Hughes 2008-03-01 09:14:02 UTC
Created attachment 15250 [details]
Patch to add CPStringBuilder
Comment 8 Andrew John Hughes 2008-03-05 21:03:17 UTC
Created attachment 15264 [details]
Move towards a CPStringBuilder-using code base
Comment 9 Andrew John Hughes 2008-03-05 21:03:43 UTC
Created attachment 15265 [details]
Move towards a CPStringBuilder-using code base
Comment 10 Andrew John Hughes 2008-03-05 21:04:08 UTC
Created attachment 15266 [details]
Move towards a CPStringBuilder-using code base
Comment 11 Andrew John Hughes 2008-03-16 22:29:15 UTC
Created attachment 15332 [details]
Move towards a CPStringBuilder-using code base
Comment 12 Andrew John Hughes 2008-03-16 22:45:10 UTC
Created attachment 15333 [details]
Move towards a CPStringBuilder-using code base
Comment 13 Andrew John Hughes 2008-03-16 23:37:42 UTC
Created attachment 15334 [details]
Move towards a CPStringBuilder-using code base
Comment 14 Andrew John Hughes 2008-03-17 00:37:54 UTC
Created attachment 15335 [details]
Abstract reflection elements of CPStringBuilder to a VM class
Comment 15 Andrew John Hughes 2008-03-17 01:30:20 UTC
Created attachment 15336 [details]
Move towards a CPStringBuilder-using code base
Comment 16 Andrew John Hughes 2008-04-27 22:01:13 UTC
Created attachment 15539 [details]
Fix substring bug
Comment 17 Andrew John Hughes 2008-05-01 00:44:05 UTC
Created attachment 15554 [details]
Move towards a CPStringBuilder-using code base
Comment 18 Andrew John Hughes 2008-05-01 00:44:38 UTC
Created attachment 15555 [details]
Move towards a CPStringBuilder-using code base
Comment 19 Andrew John Hughes 2008-05-01 00:45:09 UTC
Created attachment 15556 [details]
Use StringBuilder in the examples
Comment 20 Andrew John Hughes 2008-05-07 17:54:55 UTC
Created attachment 15593 [details]
Move towards a CPStringBuilder-using code base
Comment 21 Andrew John Hughes 2008-05-07 17:55:25 UTC
Created attachment 15594 [details]
Move towards a CPStringBuilder-using code base
Comment 22 Andrew John Hughes 2008-05-07 17:56:00 UTC
Created attachment 15595 [details]
Move towards a CPStringBuilder-using code base
Comment 23 Andrew John Hughes 2008-05-07 17:56:36 UTC
Created attachment 15596 [details]
Move towards a CPStringBuilder-using code base
Comment 24 Andrew John Hughes 2008-05-07 17:57:10 UTC
Created attachment 15597 [details]
Move towards a CPStringBuilder-using code base
Comment 25 Andrew John Hughes 2008-05-07 17:57:40 UTC
Created attachment 15598 [details]
Move towards a CPStringBuilder-using code base
Comment 26 Andrew John Hughes 2008-05-07 17:58:20 UTC
Created attachment 15599 [details]
Move towards a CPStringBuilder-using code base
Comment 27 Andrew John Hughes 2008-05-07 17:58:55 UTC
Created attachment 15600 [details]
Move towards a CPStringBuilder-using code base
Comment 28 ddaney 2008-05-07 17:59:44 UTC
Subject: Re:  We should to use StringBuilder instead
 of StringBuffer where appropriate.

gnu_andrew at member dot fsf dot org wrote:
> ------- Comment #25 from gnu_andrew at member dot fsf dot org  2008-05-07 17:57 -------
> Created an attachment (id=15598)
>  --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15598&action=view)
> Move towards a CPStringBuilder-using code base
> 
> 
I don't think it is strictly speaking necessary to attach all of these 
patches.

David Daney
Comment 29 Andrew John Hughes 2008-05-07 18:01:51 UTC
Created attachment 15601 [details]
Move towards a CPStringBuilder-using code base
Comment 30 Andrew John Hughes 2008-05-07 18:02:14 UTC
Created attachment 15602 [details]
Move towards a CPStringBuilder-using code base
Comment 31 Andrew John Hughes 2008-05-07 18:02:46 UTC
Created attachment 15603 [details]
Move towards a CPStringBuilder-using code base
Comment 32 Andrew John Hughes 2008-05-07 18:03:30 UTC
Created attachment 15604 [details]
Move towards a CPStringBuilder-using code base
Comment 33 Andrew John Hughes 2008-05-07 18:04:01 UTC
Created attachment 15605 [details]
Move towards a CPStringBuilder-using code base
Comment 34 Andrew John Hughes 2008-05-07 18:04:29 UTC
Created attachment 15606 [details]
Move towards a CPStringBuilder-using code base
Comment 35 Andrew John Hughes 2008-05-07 18:07:05 UTC
Created attachment 15607 [details]
Move towards a CPStringBuilder-using code base
Comment 36 Andrew John Hughes 2008-05-07 18:07:34 UTC
Created attachment 15608 [details]
Move towards a CPStringBuilder-using code base
Comment 37 Andrew John Hughes 2008-05-07 18:08:04 UTC
Created attachment 15609 [details]
Move towards a CPStringBuilder-using code base
Comment 38 Andrew John Hughes 2008-05-07 18:08:33 UTC
Created attachment 15611 [details]
Change tools to use StringBuilder
Comment 39 Andrew John Hughes 2008-05-07 18:10:36 UTC
All appropriate changes made.  Closing this bug.