Well, if the template size isn't going change and this is the only app
running on the machine then so be it. Chances are good that neither of those
things is true. I'd still err on the side of having a single line memory at
a time because it's not like the optimization is making it any harder to
read or understand.


Michael M. Minutillo
Indiscriminate Information Sponge
Blog: http://wolfbyte-net.blogspot.com


On Mon, Feb 7, 2011 at 10:30 AM, mike smith <meski...@gmail.com> wrote:

> On Mon, Feb 7, 2011 at 12:49 PM, Michael Minutillo <
> michael.minuti...@gmail.com> wrote:
>
>> If you're in .NET 4.0 land then I'd do something similar to this:
>>
>> public string ReplaceTokens(string src) { /* ... */ }
>>
>> File.WriteAllLines(outputFileName,
>> File.ReadLines(inputFileName).Select(ReplaceTokens));
>>
>> The ReadLines call (new to .NET 4.0) reads one line at a time and returns
>> it as you iterate over it so in theory you don't need to have the whole file
>> in memory. Don't use the ReadAllLines method on a 750MB file which DOES read
>> the whole thing in before you start.
>>
>>
>>
>
> Is that a real problem given physical RAM these days?  If you're going to
> write multiple outputs from the one template file of 750 it's going to
> rapidly get more efficient to have the template in-ram.   Wait a moment.
>  You don't work for Readers Digest, do you?  I have no desire whatever to
> make them more efficient.
>
> --
> Meski
>
> "Going to Starbucks for coffee is like going to prison for sex. Sure,
> you'll get it, but it's going to be rough" - Adam Hills
>

Reply via email to