packages feed

utf8-string 0.3.7 → 0.3.8

raw patch · 9 files changed

+50/−7 lines, 9 filesdep ~base

Dependency ranges changed: base

Files

+ CHANGELOG.markdown view
@@ -0,0 +1,4 @@+0.3.8+-----+* Performance tweaks+* bytestring-in-base flag default to False
Codec/Binary/UTF8/Generic.hs view
@@ -1,4 +1,7 @@-{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances #-}+{-# LANGUAGE CPP, MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances #-}+#if __GLASGOW_HASKELL__ >= 701+{-# LANGUAGE Trustworthy #-}+#endif -- -- | -- Module      :  Codec.Binary.UTF8.Generic
Codec/Binary/UTF8/String.hs view
@@ -1,3 +1,7 @@+{-# LANGUAGE CPP #-}+#if __GLASGOW_HASKELL__ >= 701+{-# LANGUAGE Trustworthy #-}+#endif -- -- | -- Module      :  Codec.Binary.UTF8.String
Data/ByteString/Lazy/UTF8.hs view
@@ -1,3 +1,7 @@+{-# LANGUAGE CPP, BangPatterns #-}+#if __GLASGOW_HASKELL__ >= 701+{-# LANGUAGE Trustworthy #-}+#endif -- -- | -- Module      :  Data.ByteString.Lazy.UTF8@@ -119,26 +123,35 @@               _ -> (replacement_char, 3)           _ -> (replacement_char, 2)       _ -> (replacement_char, 1)+{-# INLINE decode #-}   -- | Split after a given number of characters. -- Negative values are treated as if they are 0. splitAt :: Int64 -> B.ByteString -> (B.ByteString,B.ByteString) splitAt x bs = loop 0 x bs-  where loop a n _ | n <= 0 = B.splitAt a bs-        loop a n bs1 = case decode bs1 of+  where loop !a n _ | n <= 0 = B.splitAt a bs+        loop !a n bs1 = case decode bs1 of                          Just (_,y) -> loop (a+y) (n-1) (B.drop y bs1)                          Nothing    -> (bs, B.empty)  -- | @take n s@ returns the first @n@ characters of @s@. -- If @s@ has less than @n@ characters, then we return the whole of @s@. take :: Int64 -> B.ByteString -> B.ByteString-take n bs = fst (splitAt n bs)+take x bs = loop 0 x bs+  where loop !a n _ | n <= 0 = B.take a bs+        loop !a n bs1 = case decode bs1 of+                         Just (_,y) -> loop (a+y) (n-1) (B.drop y bs1)+                         Nothing    -> bs  -- | @drop n s@ returns the @s@ without its first @n@ characters. -- If @s@ has less than @n@ characters, then we return an empty string. drop :: Int64 -> B.ByteString -> B.ByteString-drop n bs = snd (splitAt n bs)+drop x bs = loop 0 x bs+  where loop !a n _ | n <= 0 = B.drop a bs+        loop !a n bs1 = case decode bs1 of+                         Just (_,y) -> loop (a+y) (n-1) (B.drop y bs1)+                         Nothing    -> B.empty  -- | Split a string into two parts:  the first is the longest prefix -- that contains only characters that satisfy the predicate; the second
Data/ByteString/UTF8.hs view
@@ -1,3 +1,7 @@+{-# LANGUAGE CPP #-}+#if __GLASGOW_HASKELL__ >= 701+{-# LANGUAGE Trustworthy #-}+#endif -- -- | -- Module      :  Data.ByteString.UTF8
Data/String/UTF8.hs view
@@ -1,3 +1,7 @@+{-# LANGUAGE CPP #-}+#if __GLASGOW_HASKELL__ >= 701+{-# LANGUAGE Trustworthy #-}+#endif -- -- | -- Module      :  Data.String.UTF8
System/Environment/UTF8.hs view
@@ -1,3 +1,7 @@+{-# LANGUAGE CPP #-}+#if __GLASGOW_HASKELL__ >= 701+{-# LANGUAGE Trustworthy #-}+#endif -- -- | -- Module      :  System.Environment.UTF8
System/IO/UTF8.hs view
@@ -1,3 +1,7 @@+{-# LANGUAGE CPP #-}+#if __GLASGOW_HASKELL__ >= 701+{-# LANGUAGE Trustworthy #-}+#endif ----------------------------------------------------------------------------- -- | -- Module      :  System.IO.UTF8
utf8-string.cabal view
@@ -1,5 +1,5 @@ Name:               utf8-string-Version:            0.3.7+Version:            0.3.8 Author:             Eric Mertens Maintainer:         emertens@galois.com License:            BSD3@@ -13,8 +13,11 @@ Category:           Codec Build-type:         Simple cabal-version:      >= 1.2+Extra-Source-Files: CHANGELOG.markdown + flag bytestring-in-base+  default: False  library   Ghc-options:        -W -O2@@ -23,7 +26,7 @@     build-depends: base >= 2.0 && < 2.2     cpp-options: -DBYTESTRING_IN_BASE   else-    build-depends: base < 2.0 || >= 3, bytestring >= 0.9+    build-depends: base >= 3 && < 4.8, bytestring >= 0.9    Extensions:         CPP   Exposed-modules:    Codec.Binary.UTF8.String