X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Data%2FPackedString.hs;h=46fb4baf706a8c5d9cf2ab5a8d6f03b83cc855c2;hb=e9e2a5412bb7cda8d13a063ac403d9f18ac97380;hp=0db102a8036e01e1106c3ee75cc32a5457f081d4;hpb=11cf8180e05e7219620cfbe4e6e2b83bb0ed6eaf;p=ghc-base.git diff --git a/Data/PackedString.hs b/Data/PackedString.hs index 0db102a..46fb4ba 100644 --- a/Data/PackedString.hs +++ b/Data/PackedString.hs @@ -83,6 +83,11 @@ import System.IO -- efficient operations. A 'PackedString' contains full Unicode 'Char's. newtype PackedString = PS (UArray Int Char) +-- ToDo: we could support "slices", i.e. include offset and length fields into +-- the string, so that operations like take/drop could be O(1). Perhaps making +-- a slice should be conditional on the ratio of the slice/string size to +-- limit memory leaks. + instance Eq PackedString where (PS x) == (PS y) = x == y @@ -261,7 +266,7 @@ joinPS filler pss = concatPS (splice pss) * joinPS (packString [x]) (splitPS x ls) = ls -} --- | The 'splitPS' function splits the input string on each occurance of the given 'Char'. +-- | The 'splitPS' function splits the input string on each occurrence of the given 'Char'. splitPS :: Char -> PackedString -> [PackedString] splitPS c = splitWithPS (== c) @@ -309,7 +314,7 @@ substrPS (PS ps) begin end = packString [ ps ! i | i <- [begin..end] ] -- | Outputs a 'PackedString' to the specified 'Handle'. -- -- NOTE: the representation of the 'PackedString' in the file is assumed to --- be in the ISO-8859-1 encoding. In other words, only the least signficant +-- be in the ISO-8859-1 encoding. In other words, only the least significant -- byte is taken from each character in the 'PackedString'. hPutPS :: Handle -> PackedString -> IO () hPutPS h (PS ps) = do