This is the mail archive of the
java-discuss@sourceware.cygnus.com
mailing list for the Java project.
Re: inlining and string concatenation
- To: Bryce McKinlay <bryce at albatross dot co dot nz>
- Subject: Re: inlining and string concatenation
- From: Tom Tromey <tromey at cygnus dot com>
- Date: Mon, 1 May 2000 15:45:20 -0700 (PDT)
- Cc: Java Discuss List <java-discuss at sourceware dot cygnus dot com>
- References: <87u2glsmnk.fsf@cygnus.com><390A4C7B.632FAE96@albatross.co.nz><m2vh118hlb.fsf@kelso.bothner.com><390D5561.96772B5C@albatross.co.nz>
>>>>> "Bryce" == Bryce McKinlay <bryce@albatross.co.nz> writes:
Bryce> private String[] strings;
Bryce> public FastStringConcatenator(int stringcount)
Bryce> {
Bryce> strings_count = stringcount;
Bryce> strings = new String[stringcount];
Bryce> }
It seems to me that we could allocate the String[] (or the C++
equivalent, really -- we don't need the object header) on the stack.
Since string concatenation behavior is largely known at compile time,
we can just have "tmp[slot] = <whatever>.toString()" directly
generated by the compiler.
Bryce> public FastStringConcatenator append (float fnum)
Bryce> {
Bryce> strings[i++] = Float.toString (fnum);
Bryce> return this;
Bryce> }
Things like this could be handled specially as well, if we wanted to
be tricky. We could allocate enough space on the stack for the
resulting character array and just use (our internal equivalent of)
sprintf.
Tom