Skip to content

Commit

Permalink
force copying of statically known short bytestrings
Browse files Browse the repository at this point in the history
  • Loading branch information
meiersi committed Sep 19, 2010
1 parent 20c4a93 commit c3d8373
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Text/Blaze/Renderer/Utf8.hs
Expand Up @@ -20,7 +20,7 @@ import qualified Text.Blaze.Builder.Html as B
--
fromChoiceString :: ChoiceString -- ^ String to render
-> Builder -- ^ Resulting builder
fromChoiceString (Static s) = B.fromByteString $ getUtf8ByteString s
fromChoiceString (Static s) = B.copyByteString $ getUtf8ByteString s
fromChoiceString (String s) = B.fromHtmlEscapedString s
fromChoiceString (Text s) = B.fromHtmlEscapedText s
fromChoiceString (ByteString s) = B.fromByteString s
Expand All @@ -47,17 +47,17 @@ renderBuilder = go mempty
where
go :: Builder -> HtmlM b -> Builder
go attrs (Parent open close content) =
B.fromByteString (getUtf8ByteString open)
B.copyByteString (getUtf8ByteString open)
`mappend` attrs
`mappend` B.fromChar '>'
`mappend` go mempty content
`mappend` B.fromByteString (getUtf8ByteString close)
`mappend` B.copyByteString (getUtf8ByteString close)
go attrs (Leaf begin end) =
B.fromByteString (getUtf8ByteString begin)
B.copyByteString (getUtf8ByteString begin)
`mappend` attrs
`mappend` B.fromByteString (getUtf8ByteString end)
`mappend` B.copyByteString (getUtf8ByteString end)
go attrs (AddAttribute key value h) =
go (B.fromByteString (getUtf8ByteString key)
go (B.copyByteString (getUtf8ByteString key)
`mappend` fromChoiceString value
`mappend` B.fromChar '"'
`mappend` attrs) h
Expand Down

0 comments on commit c3d8373

Please sign in to comment.