Thanks for your help, Duncan.
On Jan 12, 2009, at 6:10 AM, Duncan Coutts wrote:
Do the (ForeignPtr e) and the (Ptr e) point to the same thing? They
appear to be related because you dereference p but touch f.
It used to be the ForeignPtr was slower to dereference than a Ptr
and so
caching it like this could make it faster (but then requires lots of
careful thought about touchForeignPtr). These days ForeignPtr is
just as
fast and so you can use withForeignPtr and never have to worry about
touchForeignPtr. You'll notice ByteString works this way.
Often they point to the same thing, but not always. If they pointed to
the same thing, I wouldn't store p separately, but often p has a nonzero
offset from f. You either have to store the offset or cache the
pointer.
I found that it was both faster and simpler to cache p rather than the
offset.
Patrick
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe