[jdom-interest] Ampersand question

Elliotte Rusty Harold elharo at metalab.unc.edu
Fri Jul 14 06:01:30 PDT 2000


At 6:12 AM -0700 7/13/00, Alex Chaffee wrote:

>
>That sounds very good (really!) except for one thing:
>
>For performance reasons, you will want to be able to format() directly
>onto a stream or writer, rather than suffering the waste of
>intermediate Strings and/or StringBuffers.
>

Premature optimization is the root of all evil. I see two main use cases here:

1. You're saving into a file.
2. You're serving documents over a network.

In the first case a few hundred extra milliseconds (at most) to write 
the string into the file is trivial. You won't be doing this often 
enough for it to matter. In the second case, the network is likely to 
be your bottleneck, not the code.  In both cases the point we're 
arguing here would be completely swamped by other issues like whether 
the stream is buffered or not. I don't think any marginal performance 
gain we might get by outputting directly is grounds for complicating 
the API or the code.

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
|                  The XML Bible (IDG Books, 1999)                   |
|              http://metalab.unc.edu/xml/books/bible/               |
|   http://www.amazon.com/exec/obidos/ISBN=0764532367/cafeaulaitA/   |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:  http://metalab.unc.edu/javafaq/ |
|  Read Cafe con Leche for XML News: http://metalab.unc.edu/xml/     |
+----------------------------------+---------------------------------+



More information about the jdom-interest mailing list