3 ms·
To do it the way he described (buffer of zeros + fill): import qualified Data.Vector.Unboxed.Mutable as V encode len fields = do buffer <- V.replicate
by Peaker 13y ago
To do it the way he described (buffer of zeros + fill):
import qualified Data.Vector.Unboxed.Mutable as V
encode len fields = do
buffer <- V.replicate len 0
forM_ fields $ \(fieldPos, fieldData) ->
V.copy (V.slice fieldPos (length fieldData) buffer) fieldData
return buffer