Skip to content

Commit

Permalink
fix benches; seems good
Browse files Browse the repository at this point in the history
  • Loading branch information
raehik committed Mar 17, 2024
1 parent 13ae56d commit b45e0fb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions bench/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ data X3
| X33 Word8 (NullTerminated B.ByteString) X3
deriving stock (Generic)

instance BLen X3 where blen = blenGenericSum cDef
instance Put X3 where put = putGenericSum cDef
instance BLen X3 where blen = blenGenericSum $ blen . nullTermCstrPfxTag
instance Put X3 where put = putGenericSum $ put . nullTermCstrPfxTag

x33 :: X3
x33 =
Expand Down
5 changes: 2 additions & 3 deletions src/Binrep/Generic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import Refined.Unsafe
-- | Turn a constructor name into a prefix tag by adding a null terminator.
--
-- Not common in binary data representations, but safe and useful for debugging.
--
-- The refine force is safe under the assumption that Haskell constructor names
-- are UTF-8 with no null bytes allowed. Fairly certain that's true.
nullTermCstrPfxTag :: String -> NullTerminated B.ByteString
nullTermCstrPfxTag = reallyUnsafeRefine . Text.encodeUtf8 . Text.pack
-- ^ reallyUnsafeRefine : safe assuming Haskell constructor names are UTF-8 with
-- no null bytes allowed

0 comments on commit b45e0fb

Please sign in to comment.