[darcs-devel] darcs patch: Cache pristine directory within NoPristine.

David Roundy droundy at abridgegame.org
Thu Apr 28 06:00:17 PDT 2005


On Thu, Apr 28, 2005 at 02:31:49PM +0200, Juliusz Chroboczek wrote:
> > Because IORefs are scary beasts, and things that can disappear or
> > change after they think you have finished using them scarier still.
> 
> No, once it is created the underlying pristine tree will never change.
> The main point is that it is created lazily; the other thing is that it
> is invalidated -- the directory still exists, but we mark the Pristine
> data structure as invalid so that the next call to surely_slurp_Pristine
> will create a new directory.
> 
> The first point could be solved by using a lazy field for the pristine
> directory and some creative use of unsafePerformIO and
> unsafeInterleaveIO.  On the other hand, I don't see how to do the second
> one without using an IORef.

I'm not sure that we *want* invalidatePristine.  Couldn't we just update
the pristine, if we've already got one? Perhaps at times this would waste a
bit of IO, but it definitely seems easiest and safest.  Once we've
laboriously created a pristine, since we have to keep it around anyways, it
won't cost us much to keep it up-to-date and to reuse it.

It does seem like a lazy field and unsafePerformIO would be the way to go
about this, and then we just have to keep the cache up-to-date if it
exists.  The catch is that we have to be able to *know* if it exists... but
I'm sure this is a soluble problem--and probably an easier one than
invalidating the pristine.
-- 
David Roundy
http://www.darcs.net




More information about the darcs-devel mailing list