Skip to content

Commit

Permalink
Cosmetic renames asc -> ascii
Browse files Browse the repository at this point in the history
  • Loading branch information
hs-viktor committed Oct 9, 2023
1 parent 7f1aca0 commit 01b5f36
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 31 deletions.
8 changes: 4 additions & 4 deletions Data/ByteString/Builder.hs
Original file line number Diff line number Diff line change
Expand Up @@ -451,11 +451,11 @@ string8 = P.primMapListFixed P.char8
{-# RULES
"string8/unpackCString#" forall s.
string8 (unpackCString# s) =
ascLiteralCopy (Ptr s) (byteCountLiteral s)
asciiLiteralCopy (Ptr s) (byteCountLiteral s)

"string8/unpackFoldrCString#" forall s.
string8 (build (unpackFoldrCString# s)) =
ascLiteralCopy (Ptr s) (byteCountLiteral s)
asciiLiteralCopy (Ptr s) (byteCountLiteral s)
#-}

------------------------------------------------------------------------------
Expand All @@ -482,11 +482,11 @@ stringUtf8 = P.primMapListBounded P.charUtf8

"stringUtf8/unpackCString#" forall s.
stringUtf8 (unpackCString# s) =
ascLiteralCopy (Ptr s) (byteCountLiteral s)
asciiLiteralCopy (Ptr s) (byteCountLiteral s)

"stringUtf8/unpackFoldrCString#" forall s.
stringUtf8 (build (unpackFoldrCString# s)) =
ascLiteralCopy (Ptr s) (byteCountLiteral s)
asciiLiteralCopy (Ptr s) (byteCountLiteral s)
#-}

instance IsString Builder where
Expand Down
8 changes: 4 additions & 4 deletions Data/ByteString/Builder/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ module Data.ByteString.Builder.Internal (
-- , sizedChunksInsert

, byteStringCopy
, ascLiteralCopy
, asciiLiteralCopy
, modUtf8LitCopy
, byteStringInsert
, byteStringThreshold
Expand Down Expand Up @@ -889,9 +889,9 @@ byteStringInsert =
-- @0xC0 0x80@) null characters.
--
-- @since 0.11.5.0
{-# INLINABLE ascLiteralCopy #-}
ascLiteralCopy :: Ptr Word8 -> Int -> Builder
ascLiteralCopy = \ !ip !len -> builder $ \k br -> do
{-# INLINABLE asciiLiteralCopy #-}
asciiLiteralCopy :: Ptr Word8 -> Int -> Builder
asciiLiteralCopy = \ !ip !len -> builder $ \k br -> do
let !ipe = ip `plusPtr` len
wrappedBytesCopyStep (BufferRange ip ipe) k br

Expand Down
4 changes: 2 additions & 2 deletions Data/ByteString/Builder/Prim.hs
Original file line number Diff line number Diff line change
Expand Up @@ -668,9 +668,9 @@ primMapLazyByteStringBounded w =
-- @0xC0 0x80@) null characters.
--
-- @since 0.11.0.0
{-# DEPRECATED cstring "Use ascLiteralCopy instead" #-}
{-# DEPRECATED cstring "Use asciiLiteralCopy instead" #-}
cstring :: Addr# -> Builder
cstring s = ascLiteralCopy (Ptr s) (S.byteCountLiteral s)
cstring s = asciiLiteralCopy (Ptr s) (S.byteCountLiteral s)
{-# INLINE cstring #-}

-- | Builder for raw 'Addr#' pointers to null-terminated primitive UTF-8
Expand Down
32 changes: 16 additions & 16 deletions bench/BenchAll.hs
Original file line number Diff line number Diff line change
Expand Up @@ -251,17 +251,17 @@ largeTraversalInput = S.concat (replicate 10 byteStringData)
smallTraversalInput :: S.ByteString
smallTraversalInput = S8.pack "The quick brown fox"

ascBuf, utfBuf :: Ptr Word8
ascBuf = Ptr "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"#
utfBuf = Ptr "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xc0\x80xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"#
asciiBuf, utf8Buf :: Ptr Word8
asciiBuf = Ptr "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"#
utf8Buf = Ptr "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xc0\x80xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"#

asclit, utflit :: Ptr Word8 -> Builder
asclit str@(Ptr addr) = BI.ascLiteralCopy str (byteCountLiteral addr)
utflit str@(Ptr addr) = BI.modUtf8LitCopy str (byteCountLiteral addr)
asciiLit, utf8Lit :: Ptr Word8 -> Builder
asciiLit str@(Ptr addr) = BI.asciiLiteralCopy str (byteCountLiteral addr)
utf8Lit str@(Ptr addr) = BI.modUtf8LitCopy str (byteCountLiteral addr)

ascStr, utfStr :: String
ascStr = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
utfStr = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
asciiStr, utf8Str :: String
asciiStr = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
utf8Str = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

main :: IO ()
main = do
Expand All @@ -272,15 +272,15 @@ main = do
, benchB' "ensureFree 8" () (const (ensureFree 8))
, benchB' "intHost 1" 1 intHost
, benchB' "UTF-8 String (naive)" "hello world\0" fromString
, benchB' "UTF-8 String" () $ \() -> utflit (Ptr "hello world\xc0\x80"#)
, benchB' "UTF-8 String" () $ \() -> utf8Lit (Ptr "hello world\xc0\x80"#)
, benchB' "String (naive)" "hello world!" fromString
, benchB' "String" () $ \() -> asclit (Ptr "hello world!"#)
, benchB' "AsciiLit" () $ \() -> asclit ascBuf
, benchB' "Utf8Lit" () $ \() -> utflit utfBuf
, benchB' "strLit" () $ \() -> string8 ascStr
, benchB' "utfLit" () $ \() -> stringUtf8 utfStr
, benchB' "String" () $ \() -> asciiLit (Ptr "hello world!"#)
, benchB' "AsciiLit" () $ \() -> asciiLit asciiBuf
, benchB' "Utf8Lit" () $ \() -> utf8Lit utf8Buf
, benchB' "strLit" () $ \() -> string8 asciiStr
, benchB' "stringUtf8" () $ \() -> stringUtf8 utf8Str
, benchB' "strLitInline" () $ \() -> string8 "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
, benchB' "utfLitInline" () $ \() -> stringUtf8 "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\0XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
, benchB' "utf8LitInline" () $ \() -> stringUtf8 "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\0XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
]

, bgroup "Encoding wrappers"
Expand Down
10 changes: 5 additions & 5 deletions tests/builder/Data/ByteString/Builder/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -991,18 +991,18 @@ testsUtf8 =
testCString :: [TestTree]
testCString =
[ testProperty "cstring" $
toLazyByteString (asclit (Ptr "hello world!"#)) ==
toLazyByteString (asciiLit (Ptr "hello world!"#)) ==
LC.pack "hello" `L.append` L.singleton 0x20
`L.append` LC.pack "world!"
, testProperty "cstringUtf8" $
toLazyByteString (utflit (Ptr "hello\xc0\x80\xc0\x80world\xc0\x80!"#)) ==
toLazyByteString (utf8Lit (Ptr "hello\xc0\x80\xc0\x80world\xc0\x80!"#)) ==
LC.pack "hello" `L.append` L.singleton 0x00
`L.append` L.singleton 0x00
`L.append` LC.pack "world"
`L.append` L.singleton 0x00
`L.append` LC.singleton '!'
]

asclit, utflit :: Ptr Word8 -> Builder
asclit str@(Ptr addr) = BI.ascLiteralCopy str (S.byteCountLiteral addr)
utflit str@(Ptr addr) = BI.modUtf8LitCopy str (S.byteCountLiteral addr)
asciiLit, utf8Lit :: Ptr Word8 -> Builder
asciiLit str@(Ptr addr) = BI.asciiLiteralCopy str (S.byteCountLiteral addr)
utf8Lit str@(Ptr addr) = BI.modUtf8LitCopy str (S.byteCountLiteral addr)

0 comments on commit 01b5f36

Please sign in to comment.