----------------------------------------------------------------

-- | String encoding.
--   The algorithm based on copy avoidance and
--   selection of better result of huffman or raw.
encodeS :: WriteBuffer
        -> Bool             -- ^ Use Huffman if efficient
        -> (Word8 -> Word8) -- ^ Setting prefix
        -> (Word8 -> Word8) -- ^ Setting huffman flag
        -> Int              -- ^ N+
        -> ByteString       -- ^ Target
        -> IO ()
encodeS wbuf False set _ n bs = do
    let len = BS.length bs
    encodeI wbuf set n len
    copyByteString wbuf bs
encodeS :: WriteBuffer
        -> Bool             -- ^ Use Huffman if efficient
        -> (Word8 -> Word8) -- ^ Setting prefix
        -> (Word8 -> Word8) -- ^ Setting huffman flag
        -> Int              -- ^ N+
        -> ByteString       -- ^ Target
        -> IO ()
encodeS wbuf False set _ n bs = do
    let len = BS.length bs
    encodeI wbuf set n len
    copyByteString wbuf bs
encodeS wbuf False set _ n bs = do
    let len = BS.length bs
    encodeI wbuf set n len
    copyByteString wbuf bs