Re: Question on TemplateCache synchronization

Jonathan Revusky <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
BTW,

I rewrote Template.java yesterday night to be more memory efficient. 
Finally, you know, what I did, is I just read all the template into a 
String and create a map of lines by running through that string and 
using String.substring(..) calls. That way, since String objects are 
immutable, the substring returned just uses a region of the character 
array in the main TemplateText string.

It doesn't create a whole bunch of new character arrays like the old 
LineTableBuilder hack I wrote back when I implemented the error 
reporting stuff.

The thing is that, finally, I wonder why we bother passing around Reader 
objects and so on in this Template API. I think it might just be simpler 
to use String just about everywhere we use Reader. Or we could use 
CharSequence for generality maybe.

I mean, if we're going to keep all this text in memory anyway, why not 
just slurp it all into a String anyway and, where the TemplateLoader 
vends a Reader, just have it pass back a String and be done with it. I 
think the whole thing might just end up being a lot simpler and even 
more efficient that way.

JR




-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.