Commit f2fa8411 authored by Mike Ledger's avatar Mike Ledger

docs

parent d1b79ca1
......@@ -165,6 +165,12 @@ magicallySaveSpaceSometimes full s@(TI.Text _ _ slen) =
| T.null r -> Nothing
| otherwise -> Just (TextSlice remoffs slen)
-- | A normal 'RadixTree' stores a new 'Text' at every node. In contrast, a
-- 'CompressedRadixTree' takes a single corpus 'Text' which is indexed into by
-- nodes. This can save a lot of memory (e.g., using the radix trees from the
-- parsing benchmarks in this package, the 'CompressedRadixTree' version is
-- 254032 bytes, whereas the ordinary 'RadixTree' is a rotund 709904 bytes) at
-- no runtime cost.
data CompressedRadixTree
= CompressedRadixTree {-# UNPACK #-} !TI.Array !CompressedRadixTree1
......@@ -190,6 +196,9 @@ instance NFData CompressedRadixTree1 where
rnf (CompressedRadixAccept ts v) = ts `seq` rnf v
rnf (CompressedRadixSkip v) = rnf v
-- | Compress a 'RadixTree' given a corpus. All values in the tree be findable
-- within the corpus, though the corpus does not have to necessarily be the
-- direct source of the tree
compressBy :: Text -> RadixTree -> Maybe CompressedRadixTree
compressBy full@(TI.Text arr _ _) rt =
CompressedRadixTree arr <$> recompressT rt
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment