inlining and string concatenation

Tom Tromey tromey@cygnus.com
Mon May 1 15:45:00 GMT 2000


>>>>> "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


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /