Re: Question on TemplateCache synchronization
Daniel Dekany <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Friday, April 11, 2008, 7:54:08 PM, Jonathan Revusky wrote: > 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. However then the the source-code of tags will occupy memory needlessly. > 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. Well, I don't know why you did it... :) Personally, I use char[]-s for this purpose; that's almost like String. But, we have this backward compatibility thing, so... > 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. -- Best regards, Daniel Dekany ------------------------------------------------------------------------- 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