Patch to Throwable and StackTraceElement (reduced CPU usage)
Patrick Reinhart
patrick at reini.net
Tue Oct 11 11:34:26 UTC 2011
Hi David,
Well in the case of a "normal" Stream you are absolutely right, but in
the Throwable case it's a PrintStream (or PrintWriter) with both do
implement the java.lang.Appendable interface (as introduced in 1.5).
This interface defines the append() method suggested in my examples.
Cheers
Patrick "Reini" Reinhart
Zitat von "David Holmes" <david.holmes at oracle.com>:
> Hi Patrick,
>
>
> On 11/10/2011 3:39 PM, Patrick Reinhart wrote:
>>
>> In my opinion, this could be even written in this ways:
>>
>> for (StackTraceElement traceElement : trace)
>> s.append("\tat ").println(traceElement);
>
> I think you are confusing your streams and your StringBuilders - s
> is a stream.
>
> David
>
>
>>
>> and Similarly for:
>>
>> for (int i = 0; i <= m; i++)
>> s.append(prefix).append("\tat ").println(trace[i]);
>>
>> and the change would be only on one line ;-)
>>
>> Cheers,
>>
>> Patrick "Reini" Reinhart
>>
More information about the core-libs-dev
mailing list