[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Sorting a logfile, how would you write it?

Andrew Savige

8/12/2007 8:06:00 AM

--- William James <w_a_x_man@yahoo.com> wrote:
> Of course. But I'm willing to take that miniscule chance when
> I'm doing a write to a small file that takes a fraction of a
> second.

That may be an acceptable risk for a program written for private use.
Not so for a production program. After all, impatient users often
press [CTRL-C] in my experience, and that could cause corruption
if it occurred while the file was being rewritten.

Certainly, such a program would fail code review at my company for
anything we send to our clients.

> The question remains: doesn't using a temp file cause more
> disk fragmentation than writing directly to the original file?

Probably ... though correctness should come before performance
(I'll refrain from quoting Donald Knuth at you ;-).
And, in this case, any performance degradation with modern file
systems should be negligible.

Cheers,
/-



____________________________________________________________________________________
Sick of deleting your inbox? Yahoo!7 Mail has free unlimited storage.
http://au.docs.yahoo.com/mail/unlimitedst...

1 Answer

Gregory Brown

8/12/2007 2:03:00 PM

0

On 8/12/07, Andrew Savige <ajsavige@yahoo.com.au> wrote:
> --- William James <w_a_x_man@yahoo.com> wrote:
> > Of course. But I'm willing to take that miniscule chance when
> > I'm doing a write to a small file that takes a fraction of a
> > second.
>
> That may be an acceptable risk for a program written for private use.
> Not so for a production program. After all, impatient users often
> press [CTRL-C] in my experience, and that could cause corruption
> if it occurred while the file was being rewritten.

You can of course capture that, but you're write that it's creating
additional unnecessary work.