This is the mail archive of the java-discuss@sourceware.cygnus.com 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]

Re: inlining and string concatenation


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

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