{-# LANGUAGE BangPatterns, MagicHash, UnboxedTuples #-}{-# OPTIONS_GHC -O2 #-}-- We always optimise this, otherwise performance of a non-optimised-- compiler is severely affected---- (c) The University of Glasgow 2002-2006---- Unboxed mutable IntsmoduleFastMutInt(FastMutInt ,newFastMutInt ,readFastMutInt ,writeFastMutInt ,FastMutPtr ,newFastMutPtr ,readFastMutPtr ,writeFastMutPtr )whereimportGhcPrelude importData.BitsimportGHC.BaseimportGHC.PtrnewFastMutInt::IOFastMutInt readFastMutInt::FastMutInt ->IOIntwriteFastMutInt::FastMutInt ->Int->IO()newFastMutPtr::IOFastMutPtr readFastMutPtr::FastMutPtr ->IO(Ptra )writeFastMutPtr::FastMutPtr ->Ptra ->IO()dataFastMutInt =FastMutInt (MutableByteArray#RealWorld)newFastMutInt =IO$\s ->casenewByteArray#size s of{(#s ,arr #)->(#s ,FastMutInt arr #)}where!(I#size )=finiteBitSize(0::Int)readFastMutInt (FastMutInt arr )=IO$\s ->casereadIntArray#arr 0#s of{(#s ,i #)->(#s ,I#i #)}writeFastMutInt (FastMutInt arr )(I#i )=IO$\s ->casewriteIntArray#arr 0#i s of{s ->(#s ,()#)}dataFastMutPtr =FastMutPtr (MutableByteArray#RealWorld)newFastMutPtr =IO$\s ->casenewByteArray#size s of{(#s ,arr #)->(#s ,FastMutPtr arr #)}-- GHC assumes 'sizeof (Int) == sizeof (Ptr a)'where!(I#size )=finiteBitSize(0::Int)readFastMutPtr (FastMutPtr arr )=IO$\s ->casereadAddrArray#arr 0#s of{(#s ,i #)->(#s ,Ptri #)}writeFastMutPtr (FastMutPtr arr )(Ptri )=IO$\s ->casewriteAddrArray#arr 0#i s of{s ->(#s ,()#)}

AltStyle によって変換されたページ (->オリジナル) /