This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch: MAXPATHLEN usage - PR21821


>>> Shouldn't we now be using StringBuilder instead of StringBuffer in
>>> places like this?

Actually, StringBuilder requires a copy of the data, whereas if you
use gnu.gcj.runtime.StringBuffer, no copy is made.  StringBuilder
requires a copy since, in the absence of escape analysis, you don't
know that the user won't reset it and reuse the buffer.

We haven't been too good about using this other StringBuffer in the
CNI code.  That would be a plus.

We should move gnu.gcj.runtime.StringBuffer somewhere else and use it
preferentially all over Classpath where we do this explicitly.  That
way we could avoid both the synchronization and the copying.

Per> For CNI code it would be even better to use a stack-allocated
Per> "RawStringBuilder" struct:

When compiling from source, gcj uses gnu.gcj.runtime.StringBuffer to
implement String concatenation; we could change it to stack allocate
this too.

Per> It should also optimize uses of
Per> StringBuffer *and* StringBuilder to RawStringBuilder when safe.

Yeah.

Per> Another item for the wishlist ...

Stick 'em in bugzilla.  We lose too many good ideas.

Tom


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]