On Mon, Jun 18, 2012 at 3:53 PM, Bas van Dijk <v.dijk....@gmail.com> wrote: > Slicing is done by directly updating the pointer in the ForeignPtr: > > {-# INLINE basicUnsafeSlice #-} > basicUnsafeSlice i n (Vector _ fp) = > Vector n (updPtr (`advancePtr` i) fp) > > {-# INLINE updPtr #-} > updPtr :: (Ptr a -> Ptr a) -> ForeignPtr a -> ForeignPtr a > updPtr f (ForeignPtr p c) = > case f (Ptr p) of { Ptr q -> ForeignPtr q c } > > This saves an Int.
(This is off-topic as far as the proposal.) ByteString has an extra Ptr field so that accessing the data is fast, given that ForeignPtrs can't be unpacked. -- Johan _______________________________________________ Haskell-platform mailing list Haskell-platform@projects.haskell.org http://projects.haskell.org/cgi-bin/mailman/listinfo/haskell-platform