stringtable-atom 0.0.6.2 → 0.0.7
raw patch · 2 files changed
+12/−10 lines, 2 files
Files
- src/StringTable/Atom.hsc +8/−7
- stringtable-atom.cabal +4/−3
src/StringTable/Atom.hsc view
@@ -18,6 +18,7 @@ import qualified Data.ByteString as BS import qualified Data.ByteString.Internal as BS import qualified Data.ByteString.Unsafe as BS+import qualified System.IO.Unsafe as Unsafe import Control.Monad import Data.Binary import Data.Binary.Get@@ -40,27 +41,27 @@ fromAtomIO :: Atom -> IO a fromAtomIO a = return (fromAtom a)- fromAtom a = unsafePerformIO (fromAtomIO a)+ fromAtom a = Unsafe.unsafePerformIO (fromAtomIO a) class ToAtom a where toAtom :: a -> Atom toAtomIO :: a -> IO Atom toAtomIO a = return (toAtom a)- toAtom a = unsafePerformIO (toAtomIO a)+ toAtom a = Unsafe.unsafePerformIO (toAtomIO a) class HasHash a where hash32 :: a -> Word32 instance HasHash Atom where- hash32 a = let (x,y) = fromAtom a :: CStringLen in unsafePerformIO $ hash2 0 x (fromIntegral y)+ hash32 a = let (x,y) = fromAtom a :: CStringLen in Unsafe.unsafePerformIO $ hash2 0 x (fromIntegral y) instance HasHash BS.ByteString where- hash32 bs = unsafePerformIO $ do+ hash32 bs = Unsafe.unsafePerformIO $ do BS.unsafeUseAsCStringLen bs $ \ (x,y) -> hash2 0 x (fromIntegral y) instance HasHash String where- hash32 s = unsafePerformIO $ withCStringLen s $ \ (x,y) -> hash2 0 x (fromIntegral y)+ hash32 s = Unsafe.unsafePerformIO $ withCStringLen s $ \ (x,y) -> hash2 0 x (fromIntegral y) instance FromAtom (String -> String) where fromAtom x = shows (fromAtom x :: String)@@ -112,7 +113,7 @@ instance Monoid Atom where mempty = toAtom BS.empty- mappend x y = unsafePerformIO $ atomAppend x y+ mappend x y = Unsafe.unsafePerformIO $ atomAppend x y instance Show Atom where showsPrec _ atom = (fromAtom atom ++)@@ -130,7 +131,7 @@ unsafeIntToAtom x = Atom (fromIntegral x) unsafeByteIndex :: Atom -> Int -> Word8-unsafeByteIndex atom off = fromIntegral (unsafePerformIO $ peek (stPtr atom `advancePtr` off))+unsafeByteIndex atom off = fromIntegral (Unsafe.unsafePerformIO $ peek (stPtr atom `advancePtr` off)) foreign import ccall unsafe "stringtable_lookup" stAdd :: CString -> CInt -> IO Atom foreign import ccall unsafe "stringtable_ptr" stPtr :: Atom -> CString
stringtable-atom.cabal view
@@ -1,5 +1,6 @@ Name: stringtable-atom-Version: 0.0.6.2+Version: 0.0.7+Homepage: http://github.com/audreyt/stringtable-atom/ Category: Data, Pugs Synopsis: Memoize Strings as Atoms for fast comparison and sorting, with maps and sets Description: Memoize Strings as Atoms for fast comparison and sorting, with maps and sets@@ -7,13 +8,13 @@ License-File: LICENSE Author: John Meacham Maintainer: audreyt@audreyt.org-Copyright: John Meacham 2008, Audrey Tang 2008+Copyright: John Meacham 2008, Audrey Tang 2008, 2014 Cabal-version: >= 1.2.3 Extra-source-files: cbits/StringTable_cbits.h Build-Type: Simple-Tested-With: GHC==6.8.2, GHC==6.8.3, GHC==6.10.1, GHC==6.12.1+Tested-With: GHC==6.8.2, GHC==6.8.3, GHC==6.10.1, GHC==6.12.1, GHC==7.8.2 Flag SybInBase Description: syb was split from base version 4