Changeset 7166

Show
Ignore:
Timestamp:
09/27/05 13:52:26 (3 years ago)
Author:
autrijus
Message:

* Merged Data.FastPackedString? with Simon Marlow's FPS API.

Files:
3 modified

Legend:

Unmodified
Added
Removed
  • README

    r7117 r7166  
    3434The "UTF8" subsystem is derived from Sven Moritz Hallberg's work, 
    3535under a BSD-style license.  See src/UTF8.lhs. 
     36 
     37The "FastPackedString" subsystem is derived from Don Stewart et all's work, 
     38under a BSD-style license.  See src/Data/FastPackedString.hs. 
    3639 
    3740The "Unicode" subsystem is derived from Dimitry Golubovsky's work, 
  • src/Data/FastPackedString.hs

    r7164 r7166  
    3434        -- * Introducing and eliminating 'FastString's 
    3535        empty,        -- :: FastString 
     36        nil,          -- :: FastString -- DEPRECATED 
     37 
    3638        pack,         -- :: String -> FastString 
    3739        unpack,       -- :: FastString -> String 
     
    7880        drop,         -- :: Int -> FastString -> FastString 
    7981        splitAt,      -- :: Int -> FastString -> (FastString, FastString) 
     82        substr,       -- :: FastString -> Int -> Int -> FastString -- DEPRECATED 
    8083 
    8184        takeWhile,    -- :: (Char -> Bool) -> FastString -> FastString 
     
    122125        spanEnd,      -- :: (Char -> Bool) -> FastString -> (FastString, FastString) 
    123126        split,        -- :: Char -> FastString -> [FastString] 
     127 
    124128        tokens,       -- :: (Char -> Bool) -> FastString -> [FastString] 
     129        splitWith,    -- :: (Char -> Bool) -> FastString -> [FastString] -- DEPRECATED 
     130 
    125131        hash,         -- :: FastString -> Int32 
    126132        elemIndexLast,-- :: Char -> FastString -> Maybe Int 
     
    169175#endif 
    170176 
     177        fromForeignPtr,         -- :: ForeignPtr Word8 -> Int -> FastString 
     178        toForeignPtr,           -- :: FastString -> (ForeignPtr Word8, Int, Int) 
    171179   ) where 
    172180 
     
    270278empty = unsafePerformIO $ mallocForeignPtr 1 >>= \fp -> return $ PS fp 0 0 
    271279{-# NOINLINE empty #-} 
     280 
     281-- | /O(1)/ Alias for 'empty' to agree with old PackedString interface 
     282{-# DEPRECATED nil "Use empty instead" #-} 
     283nil :: FastString 
     284nil = empty 
    272285 
    273286-- | /O(n)/ Convert a 'String' into a 'FastString' 
     
    536549{-# INLINE drop #-} 
    537550 
     551-- | /O(1)/ 'substr' @begin end xs@ returns the substring of @xs@ between 
     552-- (and including) the two indices. 
     553{-# DEPRECATED substr "Use take/drop instead" #-} 
     554substr :: FastString -> Int -> Int -> FastString 
     555substr str begin end = take (end - begin + 1) (drop begin str) 
     556 
    538557-- | /O(1)/ 'splitAt' @n xs@ is equivalent to @('take' n xs, 'drop' n xs)@. 
    539558splitAt :: Int -> FastString -> (FastString, FastString) 
     
    782801tokens :: (Char -> Bool) -> FastString -> [FastString] 
    783802tokens p = Prelude.filter (not.null) . breakAll p 
     803 
     804{-# DEPRECATED splitWith "Use tokens instead" #-} 
     805splitWith :: (Char -> Bool) -> FastString -> [FastString] 
     806splitWith = tokens 
    784807 
    785808-- | Splits a 'FastString' into components delimited by separators, 
     
    10741097    return $ PS fp 0 l 
    10751098#endif 
     1099 
     1100fromForeignPtr :: ForeignPtr Word8 -> Int -> FastString 
     1101fromForeignPtr fp l = PS fp 0 l 
     1102 
     1103toForeignPtr :: FastString -> (ForeignPtr Word8, Int, Int) 
     1104toForeignPtr (PS ps s l) = (ps, s, l) 
    10761105 
    10771106-- | /O(n)/ Build a @FastString@ from a malloced @CString@. This value will 
  • src/cbits/fpstring.c

    r7164 r7166  
    2121#include <sys/types.h> 
    2222 
     23#ifdef USE_MMAP 
    2324#ifdef _WIN32 
    2425#include <windows.h> 
     
    2627#include <sys/mman.h> 
    2728#endif 
     29#endif 
    2830 
    2931#include "fpstring.h" 
     
    6870// mmapping... 
    6971 
     72#ifdef USE_MMAP 
    7073#ifdef _WIN32 
    7174 
     
    97100} 
    98101 
     102#endif 
    99103#endif 
    100104