[jdom-interest] Ampersand question

Jason Hunter jhunter at collab.net
Fri Jul 14 08:31:40 PDT 2000


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

I've seen enough content generation APIs have to be reworked to provide
straight writing to the stream without intermediary strings that I don't
think this is premature optimization.  This is just not letting history
repeat itself.  We should be able to come up with a design that doesn't
create intermediary strings for every item output.

-jh-





More information about the jdom-interest mailing list